djburnheim
Technical User
I'm need to use the Max worksheet function but am having trouble because the range I want to search keeps changing. The first cell in the range is always the same but the last one changes. I can get the cell reference for the last cell ok but can't work out how to define the range using it.
***code***
' Search for last row containing data
With Sheets(4).Range("A1.A200"
Set DataEnd = .Find("Total for Admin"
If Not DataEnd Is Nothing Then
LastRow = DataEnd.Offset(-3, 6).Row
End If
End With
Sheets(1).Cells(dRow + 2, dColumn) = Application.WorksheetFunction.Max(Sheets(4).Range(Cells(15, 7).Cells(LastRow, 7)))
***code***
' Search for last row containing data
With Sheets(4).Range("A1.A200"
Set DataEnd = .Find("Total for Admin"
If Not DataEnd Is Nothing Then
LastRow = DataEnd.Offset(-3, 6).Row
End If
End With
Sheets(1).Cells(dRow + 2, dColumn) = Application.WorksheetFunction.Max(Sheets(4).Range(Cells(15, 7).Cells(LastRow, 7)))