Reputation: 263
I have tried using R1C1 format and others to have borders stop at the last line of data in Column A, this will read "Overall - Total".
Sub Sumif_BD_Prem_Until_LastRow()
Dim LastRow As Long
Dim wb1 As Workbook
Set wb1 = Workbooks("macro all client v.01.xlsm")
LastRow = wb1.Sheets("CGIBill").Range("A:A").Find("Overall - Total", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LastRow1 = wb1.Sheets("CGIBill").Range("A:A").Find("Overall - Total").Row
For i = 21 To LastRow
Cells(i, 19) = Application.SumIfs(wb1.Sheets("Detail").Range("T:T"), w wb1.Sheets("Detail").Range("K:K"), Cells(i, 3), wb1.Sheets("Detail").Range("M:M"), Cells(i, 9))
Next
With Sheets("CGIBill").Range("A20:V20" & LastRow1).Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
Upvotes: 0
Views: 458
Reputation: 3960
The problem is how/where you're applying the LastRow. You need to replace the 20 value with whatever you've calculated it as.
So if you change
With Sheets("CGIBill").Range("A20:V20" & LastRow1).Borders
to
With Sheets("CGIBill").Range("A20:V" & LastRow1).Borders
You should get your expected results.
Upvotes: 1