Real Rows

  • Thread starter Thread starter Xabi
  • Start date Start date
X

Xabi

hello.

How can I know the real number of rows that has an excel sheet? I must read
it from an VFP application, but when I using COUNT method, returns all
records including empty


Thanks and regards


Xabi
 
Xabi,
Tom's line of code returns the last row number used on a worksheet. If blank
records (rows) are above the last record, the results may not be accurate.
You should sort the worksheet first to guarantee accuracy.

If the criteria of a populated record rests on a value in a praticular field
(column), this will work without sorting...

Application.CountA(ActiveSheet.Columns(1))

Dale Preuss
 
Tom's line of code returns the last row number used on a worksheet.

No it doesn't. It gives the number of rows in the used range. the used
range doesn't have to start in A1.

Also, since the OP is calling Excel from VFP, I assume he is working with a
table, so there should be no blank rows.

It is also correct the UsedRange does not necessarily reflect just populated
rows. It can overstate how many rows are actually populated, but if the OP
has imported a database, it is unlikely this would be a problem. If the OP
has a column that can be used to determine filled cells, then they can do

Columns(3).SpecialCells(xlConstants).count
 
Tom,
I stand corrected. I had never used that function without a header row, but
had data sheets with deleted records (empty rows). Since that discovery, I
have always sorted the data to remove blank rows.
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top