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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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

  • Re: How to get the coordinate of the lower-bound cell in Excel 2003 with C#
    ... >> All the others involve trapping errors. ... Tom Ogilvy ... > cells containing constants. ... No single property ...
    (microsoft.public.excel)
  • Re: C compiler to dual stack machine ?
    ... code for other languages results in small ... functions are called far more frequently, i.e., compounding the overhead of ... On a 32-bit platform, an address takes 32-bits, but in the same space you can compile several instructions that would otherwise take several cells. ...
    (comp.lang.forth)
  • Re: dynamic offsets
    ... > Adjust the range accordingly. ... I.e the real data in this example is rows 1-3 ... >> I am trying to detect the lowest number in completed row 3 and then ... >> other cells in the row ...
    (microsoft.public.excel)
  • Re: Selective formula
    ... Many thanks your formula is correctly working, I have the result I was ... that's why it didn't work on your REAL data. ... Assumes no empty cells in the column B range. ... I wonder if it could be due to a specific format of my cells, ...
    (microsoft.public.excel.misc)
  • Re: ternary cons?
    ... you can arrange cons cells in so called "improper" lists or ... But then you could build *only* the types of trees that used ... programmers to implement linked lists and a wide variety of trees too. ... Many dynamically typed languages allow implicit type definitions. ...
    (comp.lang.lisp)