...
..
While he has a seemingly elegant solution to find the last value in a
column, it relies on the fact that MS -- yet again? -- has an XL
function that doesn't match the documentation. . . . ..
. . . Yet, if the lookup_vector is not in ascending order, LOOKUP -- and all
other look up type functions -- happily return incorrect results (XL:
HLOOKUP, VLOOKUP, LOOKUP Return Incorrect Values --
http://support.microsoft.com/default.aspx?scid=kb;en-us;181201).
Aladin has been leveraging this behavior to his advantage. How long MS
can continue with such gross indifference to GIGO in the face of its
own push for "trustworthy computing" remains to be seen.
Begging the question whether Microsoft ever has or ever will match its
statements with its actions. It's done pretty well up to now, why should it
start doing so? [Tangential note: I'm not going to believe they know what
they're doing with regard to security until BY DEFAULT any and all Windows
Administrator folders are stored in different top level directories than all
other user folders and BY DEFAULT IE and OE quick install with settings that
don't make them ideal virus propogation conduits.]
Also, the solution depends on knowing the nature of the last entry --
numeric, text, or error code. If the last entry is text, the formula
doesn't work. One needs to use REPT("z",{absurdly large number}) in
place of the 9.999 value.
Um, REPT(CHAR(255),255) would be a better choice. So,
MAX(MATCH(9.99999999999999E300,A:A),MATCH(REPT(CHAR(255),255),A:A))
but this doesn't handle error values as bottommost values.
A lot more reliable resolution would be to use a one-line UDF
Public Function LastValInCol(x As Range)
LastValInCol = x.Parent.Cells(Rows.Count, x.Column).End(xlUp).Value
End Function
..
This works, but the point to Aladin's use of MATCH is that it takes advanatage
of binary search, so is potetially much faster than linear search methods. Using
a UDF eliminates much of the potential execution time advantage. Indeed, I
wouldn't want to bet that the .End(.) properties weren't implemented using
loops, stepping through ranges cell by cell.
So, given the UDF call overhead and the potentially linear nature of .End(.),
I'd guess the worksheet array formula
=MAX(IF(ISBLANK(A1),0,1),IF(ISBLANK(A2:A65536),0,ROW(A2:A65536))
is faster than a UDF.
--
1. Don't attach files to postings in this newsgroup.
2. Snip unnecessary text from quoted text. Indiscriminate quoting is wasteful.
3. Excel 97 & later provides 65,536 rows & 256 columns per worksheet. There are
no add-ins or patches that increase them. Need more? Use something else.