The information in this article applies to:
SYMPTOMSAfter you create a lookup table, you may experience either of the following symptoms:
CAUSEWhen you look up a text value, Microsoft Excel looks only at the text values in your table. Similarly, when you look up a numeric value, Microsoft Excel looks only at the numeric values. WORKAROUNDMethod 1: Include Minimum and Maximum Values for Both Text and NumbersIf you want your lookup table to be split into separate tables for text and numbers (the default), you must include minimum values for both the text and the numeric values in your lookup table.Zero is the lowest positive integer and the blank space character is the lowest printable text character. Method 2: Format All Cells as TextIf you want the table to behave the way it appears after it is sorted by Microsoft Excel, such that it returns the highest numeric value if a text value is looked up, then you must treat your table as text only. The following are two ways to do this:
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. MORE INFORMATIONIf the first column (VLOOKUP) or row (HLOOKUP) of your lookup table contains both text and numeric values, you can use Microsoft Excel to sort your table in ascending order. In this case, the numeric values will appear at the beginning of the table and the text values will appear at the end of the table. Both text and numbers are then sorted as expected. For example, the following values
will be sorted as:
However, if you attempt to use a lookup function to locate a text value
that is less than the first text value, the lookup the function returns the
#N/A error value.
It may appear that =VLOOKUP("a",A1:A6,1) should return the value 3, which is the largest value that is less than the lookup value a. However, the formula returns the #N/A error value instead. This behavior also occurs with HLOOKUP(), LOOKUP(), and MATCH() with Match Type arguments of 1 or negative one (-1). The same behavior also holds true if you attempt to look up a numeric value that is less than the first numeric value in your lookup table. Sample Visual Basic Macro Using VLookupMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.asp
Note that in order to test this sample macro, you must create a range on
sheet1 in book1 similar to the sample range above, and you must give the
range the defined name "hi" (without the quotation marks).
REFERENCESFor more information about Lookup Functions, click Contents and Index
on the Help menu (or on the Balloon Help menu if you are using a
version of the Macintosh operating system earlier than 8.0), click the
Index button in Microsoft Excel for the Macintosh Help, type the following text Lookup Functionsand then click Show Topics. Select the "About lookup and references functions" topic, and click Go To. If you are unable to find the information you need, ask the Office Assistant. For additional information about getting help with Visual Basic for Applications, please click the article number below to view the article in the Microsoft Knowledge Base: Q163435 VBA: Programming Resources for Visual Basic for Applications Additional query words: XL98 5.0 VLOOKUP LOOKUP HLOOKUP MATCH mixed
Keywords : kbdta |
Last Reviewed: September 28, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |