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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Rows In Excel

Status
Not open for further replies.

97867564534231

Technical User
Jul 15, 2003
2
0
0
GB
HI,
I have an excel spreadsheet within which I am entering data.
The amount of data entered into the spreadsheet is not fixed and will change on a daily basis. I need to be able to write some code in-order to calculate the total number of rows used on each specific day and show this in a message box.
for example
Mon = 10 rows of data are entered, the message box should say this.
Tue = 1000 rows of data are entered, the message box should say this.
Wed = 90 rows of data are entered, the message box should say this.
etc...

Thanks in advance,
 
This should do what you want...

Assumptions: data is coninuous i.e. no blanks in between data!

you have to tell excel what column you want to check! e.g. 1, 2, 3 etc.

***********************************************************

Sub test()
Dim strcolumn As Integer
Dim i As Long
Dim z As Long



strcolumn = InputBox("Which column would you like excel to count the rows for?", "Count")
For i = 1 To 65653
If Cells(i, strcolumn) = "" Then
MsgBox "There are " & z & " rows in column " & strcolumn
Exit Sub
Else
z = z + 1
End If
Next i

End Sub
 
Please see the FAQs section in the VBA forum - there are at least 2 FAQs on this topic

Rgds, Geoff
Si hoc legere scis, nimis eruditionis habes
Want the best answers to your questions ? - then read me baby one more time - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top