Article ID: 213476 - Last Review: January 24, 2007 - Revision: 2.4 XL: Unexpected Results with Mixed Text and Numbers in Lookup TableThis article was previously published under Q213476 For a Microsoft Excel 7.0 and earlier version of this article, see 113261
(http://support.microsoft.com/kb/113261/EN-US/
)
.
For a Microsoft Excel 98 version of this article, see 200855 (http://support.microsoft.com/kb/200855/EN-US/ ) . SYMPTOMS
In Microsoft Excel 97 and later, when you create a lookup table, the lookup functions may return the #N/A error value, or, if you are using the functions in a Microsoft Visual Basic for Applications procedure or macro, you may receive a "type mismatch" error, even though the values in the lookup table are sorted in ascending order and the value being looked up appears to fall within the range of the lookup table values. This behavior occurs with VLOOKUP(), HLOOKUP(), LOOKUP(), and MATCH() with Match Type arguments of 1 or negative one -1. CAUSE
This behavior can occur when text values and numeric values are mixed in a lookup table. When you look up a text value, Microsoft Excel looks only at the text values in your table and any numeric values will be overlooked. Similarly, when you look up a numeric value, Microsoft looks only at the numeric values, as in the following example:
RESOLUTION
To resolve this behavior, change all of the characters to text, use a cell reference, and enter the formula as an array, as in the following steps: NOTE: The steps in this example are a continuation of the example in the "Cause" section of this article.
MORE INFORMATIONMicrosoft 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 Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites: Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104) Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice) For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms) A Microsoft Visual Basic macro that uses a lookup function returns the following run-time error message
Type mismatch
REFERENCESFor more information about the Vlookup() worksheet function, click Microsoft Excel Help on the Help menu, type vlookup in the Office Assistant or the Answer Wizard, and then click Search to view the topic. For more information about the Hlookup() worksheet function, click Microsoft Excel Help on the Help menu, type hlookup in the Office Assistant or the Answer Wizard, and then click Search to view the topic. For more information about the Lookup() worksheet function, click Microsoft Excel Help on the Help menu, type lookup in the Office Assistant or the Answer Wizard, and then click Search to view the topic. For more information about the Match() worksheet function, click Microsoft Excel Help on the Help menu, type match in the Office Assistant or the Answer Wizard, and then click Search to view the topic. | Article Translations
|
Back to the top
