Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Excel VBA Find Last Row as get_last_row function
'Just copy the function below into a new module
'I usually call this module 'functions'
'You can then call anywhere in your scripts `get_last_row(ThisWorkbook.Sheets("sheet_1"), 1)
'It will then find you the last row of column A
`Change the interger for the second argument to use any other column
`checkout for other functions that I like to add into my 'functions' module.
Option Explicit
Function get_last_row(sheetname As String, column_number As Integer) As Long
get_last_row = Sheets(sheetname).Cells(Rows.Count, column_number).End(xlUp).row
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment