Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting rows in Excel 1

Status
Not open for further replies.

Dan01

Programmer
Joined
Jun 14, 2001
Messages
439
Location
US
Hi, How does one count the number of rows populated with data in Excel. Can one use a VBA loop? Thanks, Dan.
 
If there are no holes in your data, this code will return the rows on the active sheet.
Code:
Public Sub FindLastRow()
    Dim iRow As Long
    iRow = 1    'row that data starts
    Do While Len(Range("A" & iRow).Text) > 0
        iRow = iRow + 1
    Loop
    iRow = iRow - 1
    MsgBox iRow & " Rows of Data"
End Sub
 
That looks good DSI. Thanks a bunch. Dan.
 
Alternatively, you can try

MsgBox ActiveWorkbook.ActiveSheet.UsedRange.Rows.Count
 
Thanks Justin! Much easier.
 
Pretty cool Justin. Thanks! Dan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top