Counting populated rows in excel

N

noname

I have some rows populated in an excel sheet. Is there a way I can writ
a macro to count the number of populated rows
 
D

Dave Peterson

Can you pick out a column that's always filled in?

If yes, then maybe you could do this:

Option Explicit
Sub testme()
Dim LastRow As Long
With Worksheets("sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

MsgBox LastRow & " is the last row with data in column A"

End Sub

if there are two rows of headers, just subtract 2.
MsgBox LastRow - 2 & " is the total number of rows"

But there are lots of ways to get the number rows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top