Re: Re: How to get the rows count in EXCEL work sheet ??



You should use Karl's formula. Consider a worksheet completely empty except
for ones in A9 and A10.

MsgBox (Sheet1.Cells(Sheet1.Rows.Count, "G").End(xlUp).Row)
will return an incorrect value of 1

MsgBox (ActiveSheet.UsedRange.Rows.Count)
will return the correct value of 2
--
Gary's Student


"nickong" wrote:

Thank you , Karl

i found another way to do this,

-------------------------------------------
Sheet1.Cells(Sheet1.Rows.Count, "G").End(xlUp).Row
-------------------------------------------

and i think your suggestion ActiveSheet.UsedRange.Rows.Count is better than
that.

thank you very much~ :)




----- Original Message -----
From: "Karl E. Peterson" <karl@xxxxxxxx>
Newsgroups: microsoft.public.office.developer.vba
Sent: Friday, November 17, 2006 10:18 AM
Subject: Re: How to get the rows count in EXCEL work sheet ??


nickong wrote:
Hi,all

How to get the rows count in excel worksheet ?

-------------------------------------------
dim i As Integer
i= Sheet1.Rows.Count
-------------------------------------------
i get the number returned: 65536


but my worksheet only contain 5000 rows , how could this happen ?
how can i get the actual count number ?

which funciton should i use ???

Try ActiveSheet.UsedRange.Rows.Count
--
Working without a .NET?
http://classicvb.org/





.