PDA

View Full Version : Count rows



enfantter
02-15-2008, 04:07 AM
Hey,

I know that this might incredibly simple, but i cant seem to find the solution.
I want to count the number of rows in a sheet, in order to use it as input sort of like this:

for 0 to [number of rows]

Enfant terrible

Bob Phillips
02-15-2008, 04:11 AM
activesheet.usedrange.rows.count

Tinbendr
02-15-2008, 09:01 AM
The long version.



'Retrieve row/col info
Set wsData = Worksheets("DATA")
Set TopCell = wsData.Range("A1")
Set BtmCell = wsData.Range("O65536").End(xlUp)
Set SourceRange = Range(TopCell, BtmCell)
NumRows = SourceRange.Rows.Count


This gives you a little more flexability in that you can specify the range. In this case, a1:o(last cell that has data)

mdmackillop
02-15-2008, 11:15 AM
activesheet.usedrange.rows.count

... but only if your data starts in row 1.