VBA: Find the last row used

August 14th, 2004 | Categories: Cells, Columns & Rows | Tags: ,
-->

Do you have to run a loop down a sheet but don’t know where the data stops? ActiveSheet.UsedRange.Rows.Count might help.

1. Put this in a module

Sub LastRow()

Dim LastRow As Integer

LastRow = ActiveSheet.UsedRange.Rows.Count
MsgBox LastRow

End Sub
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
  1. MarcelB
    May 6th, 2010 at 10:47
    Reply | Quote | #1

    Works, but, if you free the last cell, UsedRange.Rows.Count does not change dynamically.