Hi,
I think I have found the solution from Ron de Bruin if anyone is interested
Sub LastRow_Example()
Dim LastRow As Long
Dim rng As Range
' Use all cells on the sheet
Set rng = Sheets("Sheet1").Cells
'Use a range on the sheet
'Set rng = Sheets("Sheet1").Range("A1:D30")
' Find the last row
LastRow = Last(1, rng)
' After the last row with data change the value of the cell in Column A
rng.Parent.Cells(LastRow + 1, 1).Value = "Hi there"
End Sub
Function Last(choice As Long, rng As Range)
Dim lrw As Long
Dim lcol As Long
Select Case choice
On Error Resume Next
Last = rng.Find(What:="*", _
After:=rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Select
End Function
https://www.rondebruin.nl/win/s9/win005.htm
Bookmarks