The tutorial explains how you can quickly cope with VLOOKUP not working problems in Excel 2013, 2010, 2007 and 2003, troubleshoot and fix common errors and overcome VLOOKUP's limitations.
In the last few articles, we have explored different aspects of the Excel VLOOKUP function. If you have been following us closely, by now you should be an expert in this area : )
However, it's not without a reason that many Excel specialists consider VLOOKUP to be one of the most intricate Excel functions. It has a ton of limitations and specificities, which are the source of various problems and errors.
In this article, you will find simple explanations of VLOOKUP's #N/A, #NAME and #VALUE error messages as well as solutions and fixes. We will start with the most frequent cases and most obvious reasons why vlookup is not working, so it might be a good idea to check out the below troubleshooting steps in order.
In Vlookup formulas, the #N/A error message (meaning "not available") is displayed when Excel cannot find a lookup value. There can be several reasons why that may happen.
1. A typo or misprint in the lookup value
It's always a good idea to check the most obvious thing first : ) Misprints frequently occur when you are working with really large data sets consisting of thousands of rows, or when a lookup value is typed directly in the formula.
2. #N/A in approximate match VLOOKUP
If you are using a formula with approximate match (range_lookup argument set to TRUE or omitted), your Vlookup formula might return the #N/A error in two cases:
- If the lookup value is smaller than the smallest value in the lookup array.
- If the lookup column is not sorted in ascending order.
3. #N/A in exact match VLOOKUP
If you are searching with exact match (range_lookup argument set to FALSE) and the exact value is not found, the #N/A error is also returned. See more details on how to properly use exact and approximate match VLOOKUP formulas.
4. The lookup column is not the leftmost column of the table array
As you probably know, one of the most significant limitations of Excel VLOOKUP is that it cannot look to its left, consequently your lookup column should always be the left-most column in the table array. In practice, we often forget about this and end up with VLOOKUP not working because of the N/A error.
Solution: If it is not possible to restructure your data so that the lookup column is the left-most column, you can use a combination of Excel's INDEX and MATCH functions, as a more versatile alternative to VLOOKUP. You will find the detailed info and a formula example in this tutorial - INDEX / MATCH formula to lookup values to left.
5. Numbers are formatted as text
Another source N/A errors in VLOOKUP formulas is numbers being formatted as text, either in the main or lookup table.
This usually occurs when you import data from some external database or if you've typed an apostrophe before a number to indicate a leading zero.
The most obvious indications of numbers being formatted as text are shown in the screenshot below.
The numbers can also be stored in the General format. In this case, there's only one noticeable sign - numbers get aligned to the left side of a cell, while numbers stored as numbers are aligned to the right by default.
Solution: If this is just a single number, simply click on the error icon and choose "Convert To Number" from the context menu.
If multiple numbers are affected, select them all, right-click the selection, then choose Format Cells > Number tab > Number and click OK.
6. Excess leading or trailing spaces
This is the least obvious cause of the Vlookup N/A error because a human eye can hardly spot those extra spaces, especially when working with big tables where most of the entries are below the scroll.
Solution 1: Extra spaces are in the main table (with VLOOKUP formulas)
If excess spaces occur in your main table, you can ensure the correct work of your Vlookup formulas by wrapping the lookup_value argument with the TRIM function:
Solution 2: Extra spaces are in the lookup table (lookup column)
If extra spaces occur in the lookup column, there is no easy way to avoid VLOOKUP #N/A errors. Instead of VLOOKUP, you can use an array formula with a combination of INDEX / MATCH and TRIM functions:
Since this is an array formula, don't forget to press Ctrl + Shift + Enter rather than a usual Enter keystroke to properly complete it:
For more information about using INDEX / MATCH in Excel, please check out this tutorial: INDEX & MATCH in Excel - a better alternative to VLOOKUP.
In general, Microsoft Excel displays the #VALUE! error if a value used in the formula is of a wrong data type. In respect to VLOOKUP, there are two common sources of the VALUE! error.
1. Lookup value exceeds 255 characters
Please be aware that the VLOOKUP function cannot look up values containing 256 characters or more. If your lookup values exceed this limit, you will end up having the VALUE error:
Solution: Use an analogous INDEX /MATCH formula instead. In the above example, the following INDEX / MATCH function works perfectly:
You can learn more about using INDEX / MATCH in Excel in this tutorial.
2. Full path to the lookup workbook is not supplied
If you are pulling data from another workbook, you have to include the full path to that file. More precisely, you have to enclose the workbook's name (including the extension) in square brackets , and then specify the sheet's name followed by the exclamation mark. Also, you should have apostrophes around all this in case either a workbook or spreadsheet name contains spaces.
Here's the structure of the complete formula to do a vlookup from another workbook:
=VLOOKUP(lookup_value, '[workbook name]sheet name'!table_array, col_index_num, FALSE)
A real formula might look similar to this:
The above formula will search for the value of cell A2 in column B of Sheet1 in the "New Prices" workbook, and return a matching value from column D.
If any element of the path is missing, your VLOOKUP formula won't work and return the #VALUE error (unless the lookup workbook is currently open).
For more info about VLOOKUP formulas referencing another Excel file, please check out this tutorial: How to do vlookup from a different workbook.
3. The col_index_num argument is less than 1
It's hard to imagine a situation when someone would want to enter a number less than "1" to specify the column to return values from. Though, it may happen if this argument is returned by some other Excel function nested in your Vlookup formula.
So, if the col_index_num argument happens to be less than 1, your Vlookup formula will return the #VALUE! error too.
If the col_index_num argument is greater than the number of the columns in the specified table array, Vlookup formulas return the #REF! error.
This is the easiest case - the NAME error appears if you've accidentally misspelled the function's name.
The solution is obvious - check the spelling : )
Apart from having a fairly complicated syntax, VLOOKUP has arguably more limitations than any other Excel function. Because of these limitations, seemingly correct Vlookup formulas might often deliver results different from what you expect. Below you will find solutions for a few common scenarios when VLOOKUP fails.
1. VLOOKUP is case-insensitive
The VLOOKUP function does not distinguish case and teats lowercase and UPPERCASE characters as identical. So, if your table includes several similar entries that differ in the uppercase or lowercase chars only, the Vlookup formula will return the first found value regardless of the case.
Solution: Use another Excel function that can do a vertical lookup (LOOKUP, SUMPRODUCT, INDEX / MATCH) in combination with the EXACT function that can match case. You can find the detailed explanations and formula examples in this tutorial - 4 ways to do a case-sensitive vlookup in Excel.
2. VLOOKUP returns the first found value
As you already know, Excel VLOOKUP returns the first value it finds in the return column that matches the lookup value. However, you can force it to bring the 2nd, 3rd, 4th or any other occurrence you want. If you need to get all duplicate occurrences, you will have to use a combination of the INDEX, SMALL and ROW functions.
Solutions: Formula examples are available for download here:
3. A new column was inserted or removed from the table
Regrettably, VLOOKUP formulas stop working every time when a new column is deleted from or added to a lookup table. This happens because the syntax of the VLOOKUP function requires that you supply the entire table array as well as a certain number indicating which column you want to return the data from. Naturally, both the table array and the return column's number change when you remove an existing column or insert a new one.
Solution: INDEX / MATCH comes to the rescue again : ) In INDEX & MATCH formulas, you specify the lookup and return columns separately, and as a result you can delete or insert as many columns as you want without worrying about updating every associated vlookup formula.
4. Cell references changed when copying the formula to other cells
The heading gives an exhaustive explanation of the problem, right?
Solution: Always use absolute cell references (with the $ sign) in table arrays, e.g. $A$2:$C$100 or $A:$C. In the formula bar, you can quickly switch between different reference types by pressing F4.
VLOOKUP with IFERROR / ISERROR
If you do not want to intimidate your users with all those N/A, VALUE or NAME error messages, you can return a blank cell instead, or display your own message. You can do this by wrapping your VLOOKUP formula in the IFERROR function in Excel 2013, 2010 and 2007 or with IF / ISERROR in earlier Excel versions.
Using VLOOKUP with IFERROR
The syntax of the IFERROR function is simple and self-explanatory : )
Meaning, you enter the value to check for an error in the 1st argument, and in the 2nd argument you specify what to return if an error occurs.
For example, the following IFERROR / VLOOKUP formula returns a blank cell when the lookup value is not found:
If you'd rather display your own message instead of a standard Vlookup error, type it between the quotation marks, like this:
=IFERROR(VLOOKUP($F$2,$B$2:$C$10,2,FALSE),"Oops, no match is found. Please try again!")
Using VLOOKUP with ISERROR
Since the IFERROR function was introduced in Excel 2007 only, in lower Excel versions you will have to use the combination of IF and ISERROR functions in this way:
For example, here's the IF / ISERROR / VLOOKUP formula analogous to the IFERROR / VLOOKUP formula above:
=IF(ISERROR(VLOOKUP($F$2,$B$2:$C$10,2,FALSE)), "", VLOOKUP($F$2,$B$2:$C$10,2,FALSE))
That's all for today. Hopefully, this short tutorial will help you cope with all possible VLOOKUP errors and get your formulas to work in the way you want.