Aladin Akyurek
View profile
More options Dec 14 2003, 9:00 pm
Newsgroups: microsoft.public.excel.worksheet.functions
From: "Aladin Akyurek" <akyu...@xs4all.nl>
Date: Sun, 14 Dec 2003 19:49:47 +0100
Local: Sun, Dec 14 2003 8:49 pm
Subject: Re: Help with LOOKUP (golf handicaps)
Reply to author | Forward | Print | Individual message | Show original | Report this message | Find messages by this author
"Peo Sjoblom" <terr...@mvps.org> wrote in message
news:uZdcQUmwDHA.540@tk2msftngp13.phx.gbl...
> I also believe it is a bug since the help files says that the array should
> be in ascending order and you would expect the #N/A error if not.
> The problem is if MS fixes this "bug" and then it won't work. I'd rather
> use something else.
I fail to understand how the following proposition/argument forces one to
conclude a bug:
"[T]he help files says that the array should be in ascending order and you
would expect the #N/A error if not."
It seems to me quite probable that the lookup functions in Excel share the
same procedures. It's quite plausible that Excel's code contain the
following procedures:
[A] Linear/sequential search (LS).
Binary search (BS).
[C] Used range (UR).
It's also quite certain that
=MATCH(v,X,1)
=VLOOKUP(v,Y,n,1)
bound to activate UR and BS. I admit to be less certain about UR, although I
believe the behavior of the lookup functions strongly suggest it.
Additionally, this is of capital importance, these functions do not call
upon some procedure which verifies whether X or INDEX(Y,0,1) is sorted in
ascending order. That such a check/test is NOT carried out is certain for an
obvious reason: Speed. MATCH et al would not be as fast as we know them when
such a test should be included. I'm happy to observe that the programmers at
MS did not include such a test.
I strongly reject an application developer's view that Excel itself should
check whether a user is not passing an unsorted object (array or range) to
these functions. The article
http://support.microsoft.com/default.aspx?scid=kb;en-us;181201 warns against
unintended use of match-type (range-lookup) TRUE/1 in lookup functions, not
revealing a bug about them, as sometimes pointed out.
Now back to the use of BigNum (9.99999999999999E+307) and BigStr
(REPT("z",255)...
BigNum and BigStr are extremely rare events in data Excel is used to
process. That's why it's safe to use them as lookup values in an expression
that will invoke BS. Schematically,
=MATCH(BigNum/BigStr,X,1)
will invoke:
BS(BigNum/BigStr,UR(X))
Given the foregoing, we are to bound to get the last value in X because the
last value will be the last half of data BS will be examining. Since the
last examined value <= BigNum/BigStr, MATCH (or ther lookup functions) will
return it tout court.
Hope it's clear that only an *ascending order check* would allow Excel to
return #N/A regarding the formulas under discussion. A software programmer
should definitely reject adding a procedure for such a test to the
underlying system for performance reasons.