Skip to content

Instantly share code, notes, and snippets.

@hoffstein
Created July 27, 2011 13:41
Show Gist options
  • Save hoffstein/1109374 to your computer and use it in GitHub Desktop.
Save hoffstein/1109374 to your computer and use it in GitHub Desktop.
Excel find last row
Function FindLastRow(Optional sheetToSearch As Worksheet) As Long
If sheetToSearch Is Nothing Then Set sheetToSearch = ActiveSheet
On Error GoTo handler
FindLastRow = sheetToSearch.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Exit Function
handler:
FindLastRow = 1 ' No data on sheet
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment