Article ID: 191112 - Last Review: August 8, 2006 - Revision: 2.0 XL98: Returning the First or Last Match in an ArrayThis article was previously published under Q191112 For a Microsoft Excel 97 and later version of this article, see 214069
(http://support.microsoft.com/kb/214069/EN-US/
)
.
On This PageSUMMARY
In Microsoft Excel 98 Macintosh Edition you can use the LOOKUP() function
to search for a value within an array of sorted data and return the
corresponding value contained in that position within another array. If the
lookup value is repeated within the array, it will return the last match
encountered. This behavior is true for the VLOOKUP(), HLOOKUP(), and
LOOKUP() functions.
To find the first value instead of the last value in an array, you can use the INDEX() and MATCH() functions. MORE INFORMATION
The example below contrasts the results you get when you use the LOOKUP()
function with the results you get when you use the INDEX() and MATCH()
functions:
ExampleIn a new worksheet, type the following data:A1: 1 B1: Red C1: =LOOKUP(1,A1:A4,B1:B4) A2: 1 B2: Blue C2: =INDEX(A1:B4,MATCH(1,A1:A4,0),2) A3: 2 B3: Orange A4: 3 B4: Yellow Note that when you use the INDEX() and MATCH() functions, the lookup array does not need to be sorted in ascending order; however you must specify a match_type argument of 0 in order to return the correct value. REFERENCES
For more information about the LOOKUP Function, click the Office Assistant,
type "lookup," click Search, and then click to view "LOOKUP."
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base: 179216
(http://support.microsoft.com/kb/179216/EN-US/
)
OFF98: How to Use the Microsoft Office Installer Program
| Article Translations
|

Back to the top
