Thread: Count rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Count rows

Hi
in your case remove the space between the apostrophes:
Private Sub CountRows()
Dim iCount As Long
iCount = 1
While Sheet1.Range("B" & iCount).Value < ""
iCount = iCount + 1
Wend
End Sub


Or use
icount=application.counta(range("B:B"))


--
Regards
Frank Kabel
Frankfurt, Germany


Hugh wrote:
Hi there,

How to count data rows? I tried following sub. It did not
work.

Private Sub CountRows()
Dim iCount As Long
iCount = 1
While Sheet1.Range("B" & iCount).Value < " "
iCount = iCount + 1
Wend
End Sub

Thanks in advance for your help.