View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default used range question

It isn't a bug - it is an incorrect interpretation of what UsedRange
defines. UsedRange defines the area Excel maintains detailed information
on. An excel worksheet can have 65536 rows x 256 columns, but any area that
is not used, is virtual. Excel does not maintain any information on that
area. Other changed besides containing visible values can cause excel to
maintain information on an area.

If your worksheets is set up like a database with information beginning in
A1, try using

Range("A1").CurrentRegion

--
Regards,
Tom Ogilvy

"Andreas Beresko" wrote in message
...
Hi,

I'm using Office Automation to work on an excelsheet...
I need to count the filled rows, I do this by following code:

Range range;
Range usedRange;
range = actualSheet.GetUsedRange();
usedRange = range.GetRows();
int nRows = usedRange.GetCount();

When I create a new Excel Sheet this works fine, but with some files i get
wrong values in nRows.
The file www.beresko.de/test.xls has 1220 filled rows but my code returns

a
value of 2295.

Is this my fault or a bug, can anyone help me?

best regards
Andreas