N noname Nov 11, 2003 #1 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
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 Nov 12, 2003 #2 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.
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.