ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Real Rows (https://www.excelbanter.com/excel-programming/314604-real-rows.html)

Xabi

Real Rows
 
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



Tom Ogilvy

Real Rows
 
activesheet.usedrange.rows.count

--
Regards,
Tom Ogilvy

"Xabi" wrote in message
...
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





Dale Preuss[_2_]

Real Rows
 
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 Ogilvy" wrote:

activesheet.usedrange.rows.count

--
Regards,
Tom Ogilvy

"Xabi" wrote in message
...
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






Tom Ogilvy

Real Rows
 
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



--
Regards,
Tom Ogilvy


"Dale Preuss" wrote in message
...
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 Ogilvy" wrote:

activesheet.usedrange.rows.count

--
Regards,
Tom Ogilvy

"Xabi" wrote in message
...
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








Dale Preuss[_2_]

Real Rows
 
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

"Tom Ogilvy" wrote:

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



--
Regards,
Tom Ogilvy


"Dale Preuss" wrote in message
...
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 Ogilvy" wrote:

activesheet.usedrange.rows.count

--
Regards,
Tom Ogilvy

"Xabi" wrote in message
...
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










All times are GMT +1. The time now is 02:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com