Basz > said:
. . . Would you care to explain how it works? ....
hgrove wrote: ....
....
LOOKUP as well as VLOOKUP and MATCH searching for approximate matches (4th
or 3rd argument FALSE or 0, respectively) seem to begin by trying to bracket
the lookup value, and so far through Excel 2003 they predictably stop at the
final numeric value in the range if the lookup value is greater than any in
the range. Further, and *vitally*, LOOKUP and these other functions ignore
error values (or any other nonnumeric values) in the lookup range.
In this formula, MID(..) in LOOKUP's 2nd argument returns an array of all
individual characters in the value of A1 as separate strings followed by ""
strings. For example, MID("foo",{1;2;3;4},1) returns {"f";"o";"o";""}. These
are each compared to a space character, " ", returning an array of TRUE or
FALSE values. The formula then divides 1 by each of these values. The
arithmetic operation converts the TRUEs to 1s and the FALSEs to 0s, so the
result is an array of 1s and #DIV/0! errors.
At this point, none of the values in LOOKUP's 2nd argument array are greater
than 1, so looking for 2 in this range will locate the last 1, which
corresponds to the last space in A1. It then returns the corresponding value
in its 3rd argument, which is just a sequence of integers.