Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Created July 31, 2021 01:16
Show Gist options
  • Select an option

  • Save stevesohcot/1ed9c738dddf74c4313f30572139faf1 to your computer and use it in GitHub Desktop.

Select an option

Save stevesohcot/1ed9c738dddf74c4313f30572139faf1 to your computer and use it in GitHub Desktop.
VBA Excel - Get Row Count
Public Function HowManyRows(sheetName As String) As Long
'Find out how many row there are
' Assumes the first column does NOT have a blank in it
Sheets(sheetName).Select
Range("A1").Select
Selection.End(xlDown).Select
Dim totalRows As Long
totalRows = ActiveCell.Row ' do NOT subtract one for the header
HowManyRows = totalRows
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment