Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Number and Text Filters Examples in Excel
  • Understanding Anova in Excel
  • How To Sort One Column or Multiple Columns in Excel
  • Error Bars in Excel
  • How To Perform and Interpret Regression Analysis in Excel

References

  • How to create dynamic named range with OFFSET in Excel
  • Complete List of Excel Lookup and Reference Functions, References and Examples
  • How to get relative column numbers in a range in Excel
  • Multi-criteria lookup and transpose in Excel
  • INDEX function: Description, Usage, Syntax, Examples and Explanation

Data Validations

  • Excel Data validation must not contain
  • Excel Data validation must begin with
  • Excel Data validation only dates between
  • Excel Data validation require unique number
  • Excel Data validation date in next 30 days

VLOOKUP with numbers and text in Excel

by

This tutorial shows how to calculate VLOOKUP with numbers and text in Excel using the example below;

Formula

=VLOOKUP(val&"",table,col,0)

Explanation

A common problem with VLOOKUP is a mismatch between numbers and text. Either the first column in the table contains lookup values that are numbers stored as text, or the table contains numbers, but the lookup value itself is a number stored as text.

In either case, VLOOKUP will return an #N/A error, even when there appears to be a match. In the example below, each planet has an id based on position from the sun. In cell H3 we have a simple VLOOKUP formula looking for the number 3 from cell H2. The result is the #N/A error, even though 3 is clearly in the table.

Worked Example:   Perform case-sensitive Lookup in Excel

One solution is to convert both the first column in the table and the lookup value to the same type: either numbers or text. However, if you don’t have control over both the table and the lookup value, or if it’s simply not practical to convert values, you can modify the VLOOKUP formula to coerce the lookup value to match the type in the table. In this case, we can revise the VLOOKUP formula to concatenate an empty string to the lookup value, which converts the lookup value to text:

=VLOOKUP(id,planets,2,0)    // original
=VLOOKUP(id&"",planets,2,0) // revised

In the worksheet, the revised formula takes care of the error:

Worked Example:   VLOOKUP by date in Excel

How this formula works

When you concatenate an empty string (“”) to a number, it converts the number to text. You could also do the same thing with a longer formula that utilizes the TEXT function to convert to text :

=VLOOKUP(TEXT(id,"@"),planets,2,0)

If you have both numbers and text

If you can’t be certain when you’ll have numbers and when you’ll have text, you can cater to both options by wrapping VLOOKUP in IFERROR and writing a formula that handles both cases:

=IFERROR(VLOOKUP(id,planets,3,0),VLOOKUP(id&"",planets,3,0))

Here, we first try a straight VLOOKUP formula that assumes both lookup value and the first column in the tables are numbers. If that throws and error, we try again with the revised formula. If that fails, VLOOKUP will return the #N/A error.

Worked Example:   Self-contained VLOOKUP in Excel

Post navigation

Previous Post:

Weighted average in Excel

Next Post:

Win loss points calculation in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • Not Equal To ‘<>‘ operator in Excel
  • IFNA function: Description, Usage, Syntax, Examples and Explanation
  • OR function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel XOR Function
  • IF function: Description, Usage, Syntax, Examples and Explanation

Date Time

  • How to calculate future date say 6 months ahead in Excel
  • Find Last Day of the Month in Excel
  • YEAR function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate next scheduled event in Excel
  • Add years to date in Excel

Grouping

  • How to randomly assign data to groups in Excel
  • Calculate conditional mode with criteria in Excel
  • Group arbitrary text values in Excel
  • Group times into unequal buckets in Excel
  • Group numbers with VLOOKUP in Excel

General

  • Subtotal invoices by age in Excel
  • Lock Cells in a Worksheet Excel
  • How to choose page/paper size in Excel before Printing
  • How to calculate percent of goal in Excel
  • How to count total number of cells in a rectangular range in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning