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 Mike Lewis 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
Jun 14, 2001
439
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
 
Pretty cool Justin. Thanks! Dan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top