Excel: Find the first empty row on the spreadsheet Quote:How to find the first empty row on a spreadsheet
In a new module paste the following macro code and run it:
Code:
Public Sub test()
Dim wks As Worksheet
Set wks = ActiveSheet
With wks.UsedRange
Debug.Print "Used Range=" & .Address
Debug.Print "First row=" & .Rows(1).Row
Debug.Print "Last row=" & .Rows(.Rows.Count).Row
Debug.Print "First empty row=" & .Rows(.Rows.Count).Row + 1
End With
End Sub
Output:
Used Range=$B$9:$F$19
First row=9
Last row=19
First empty row=20