To add to Bob's very lucid explanation, an excellent way to actually *see*
what a particular formula is doing is to select parts of it (individual
functions or various combinations) in the formula bar, and then hit <F9>.
This displays the individual performances of the various functions, or their
results when combined.
I did screw up using that LARGE Row array at the end, which Bob picked up on
and revised.
I was trying something and forgot to change it.
BUT, we can use that to see what the formula is doing.
Let's use this formula for an example:
=LOOKUP(99^99,--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW(
1:50)))
In the formula bar ... select:
MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW(1:50))
And then hit <F9>
Be sure to hit <Esc> when you're done looking, because hitting <Enter> will
destroy the formula in that cell!
Now, include the unary in the selection, and see what <F9> displays.
--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW(1:50))
You'll see just about what Bob described.
Change the formula by reducing the size of the Row array to:
=LOOKUP(99^99,--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW(
1:25)))
Now, when you select the Mid() function, with and without the unary, and hit
<F9>, you see the *elimination* of all that *duplication* at the end.
Bob's revision sizes the elements in the array to almost only what is
necessary for the individual cell's contents, eliminating a great deal of
duplication that is created when an arbitrary guess is used for the array
size:
=LOOKUP(99^99,--MID(A3,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&"0123456789")),
ROW(INDIRECT("1:"&LEN(A3)))))
The point here being, use the <F9> evaluation technique to *see* what your
formula is actually doing.
When you create a formula and hit <Enter>, and all you get is an error
message, OR, an incorrect return, this method can help you a lot in making
the proper revisions.
This will not tell you WHY something is taking place, but it WILL tell you
WHAT is happening!