ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro for Counting the number of records in a worksheet (https://www.excelbanter.com/excel-programming/366438-macro-counting-number-records-worksheet.html)

Sri Ram[_2_]

Macro for Counting the number of records in a worksheet
 
I need to count the number of records in worksheet leaving the empty rows
using VBA code.Is there anyway to do it?

jetted[_8_]

Macro for Counting the number of records in a worksheet
 

hi

Assuming the data is in column A

Sub test()
rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
MsgBox rowcount
End Sub


--
jetted
------------------------------------------------------------------------
jetted's Profile: http://www.excelforum.com/member.php...o&userid=17532
View this thread: http://www.excelforum.com/showthread...hreadid=558896


alf bryn

Macro for Counting the number of records in a worksheet
 
If you just want to count cells with values in column A you could do like
this:

Sub Test()
Dim iLastRow As Long
Dim i As Long

Range("C3").Value = 0

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "A").Value < "" Then
Range("C3").Value = Range("C3").Value + 1
End If
Next i

End Sub



"jetted" wrote in
message ...

hi

Assuming the data is in column A

Sub test()
rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
MsgBox rowcount
End Sub


--
jetted
------------------------------------------------------------------------
jetted's Profile:
http://www.excelforum.com/member.php...o&userid=17532
View this thread: http://www.excelforum.com/showthread...hreadid=558896





All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com