VBA Used Range - Count The Number of Used Rows or Columns - VBA Code For Row Count Examples
VBA Used Range - Count The Number of Used Rows or Columns - VBA Code For Row Count Examples
examples/)
MsgBox ActiveSheet.UsedRange.Rows.Count
Do you have to run a loop down a sheet but don’t know where the
data stops? ActiveSheet.UsedRange.Rows.Count might help.
Sub LastRow()
LastRow = ActiveSheet.UsedRange.Rows.Count
MsgBox LastRow
End Sub
Sub LastCol()
ColRow = ActiveSheet.UsedRange.Col.Count
In this example the code will write “FirstEmpty” in the �rst empty
cell in column “d”
MsgBox ActiveSheet.UsedRange.Columns.Count
I am also aware that occasionally Excel thinks the last row exists
somewhere, but the row is actually empty. I’ve seen this a few times
after importing data. From BeyondTechnology:
(/out/easyvba)
(/vba-code-generator/)
(/vba-code-
generator/)
ABOUT AUTOMATE EXCEL
FORMULAS LIST
(HTTPS://WWW.AUTOMATEEXCEL.COM
/FORMULAS/)
FUNCTIONS LIST
(HTTPS://WWW.AUTOMATEEXCEL.COM
/FUNCTIONS/)
SHORTCUT COACH
(HTTPS://WWW.AUTOMATEEXCEL.COM
/SHORTCUTCOACH/)
NEWSLETTER SIGNUP
First Name
SUBMIT