Skip to content

Instantly share code, notes, and snippets.

@hoffstein
Created July 27, 2011 13:41

Revisions

  1. Benjamin Hoffstein created this gist Jul 27, 2011.
    8 changes: 8 additions & 0 deletions gistfile1.vb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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