Re: How to get the coordinate of the lower-bound cell in Excel 2003 with C#



>> All the others involve trapping errors.

Even though Norman's method has error handling, it can be avoided by testing
for nothing.
--
Regards,
Tom Ogilvy

"Harlan Grove" <hrlngrv@xxxxxxx> wrote in message
news:eI4qR82fFHA.1048@xxxxxxxxxxxxxxxxxxxxxxx
> "Norman Jones" <normanjones@xxxxxxxxxxxxxxxxxxx> wrote...
> ...
> >This does not assist the OP in his quest to determine the last cell "with
> >real data", as explicitly stipulated.
>
> OK, but sometimes other languages only have access to properties, not
> methods. If that's the case, then iteration within UsedRange using the max
> row and column bounds could be one approach.
>
> All the others involve trapping errors. One alternative involves using
> UsedRange.SpecialCells in 2 calls to find cells containing formulas and
> cells containing constants. Take the max of the row and columns indices of
> the last cells in each (e.g., with cf containing the cells containing
> formulas as returned by SpecialCells,
>
> cf.Cells(cf.Cells.Count).Row
>
> and similarly for columns).
>
> As for your approach, cells containing just a prefix character, ', could
be
> considered cells containing data. Your Find method call won't find them.
>
> Also, if data looked like
>
> ___A__B__C
> 1__x_____y
> 2_________
> 3__z______
>
> your approach would return cell A3, but the column index wouldn't reflect
> that there's anything to the right of column A. You'd need a second Find
> call going columnwise to ensure you also find the rightmost column.
>
> Returning the 'last cell' needs to be robustly handled. No single property
> or method call does that.
>
>


.



Relevant Pages