View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default used range question

Andreas,

When the used range gets set, it stays at that point even if rows get
deleted. You need to force a reset, so see
http://www.contextures.com/xlfaqApp.html#Unused for some help.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"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