VLOOKUP not working? 7 reasons for #N/A and wrong answers, and how to fix each one
Your VLOOKUP is not working. Either it shows #N/A for a code you can see in the list, or worse, it gives you a number that looks fine but is wrong.
This post walks through the seven causes that come up most often, how to spot each one, and how to fix it. Work down the list in order. Most broken lookups are fixed by the first four.
All the examples use this price list from Aisha's stationery supplier in Johannesburg, in A1:C6:
| A | B | C | |
|---|---|---|---|
| 1 | Code | Item | Price |
| 2 | P100 | Pens (box of 50) | R185 |
| 3 | P200 | A4 paper (ream) | R95 |
| 4 | P300 | Stapler | R140 |
| 5 | P400 | Whiteboard markers | R120 |
| 6 | P500 | Lever arch file | R45 |
The working formula, with the code typed in E2, is:
=VLOOKUP(E2,$A$2:$C$6,3,FALSE)
1. The missing FALSE: a wrong value with no error
This is the most dangerous mistake, because nothing looks broken.
VLOOKUP's fourth argument decides between exact match (FALSE) and approximate match (TRUE). If you leave it out, Excel uses TRUE. Approximate match looks for the largest value that is less than or equal to what you typed, and it expects the first column to be sorted.
Here's what that does. Aisha types code P350, which doesn't exist. With FALSE, she gets #N/A and knows something is off. Without FALSE:
=VLOOKUP(E2,$A$2:$C$6,3)
Excel finds P300, the closest code below P350, and returns R140, the stapler price. No error, no warning.
If the list isn't sorted, it gets worse. Microsoft notes that approximate match on an unsorted first column can return values you don't expect. That can include the price of a completely different product for a code that is in the list.
Fix: add FALSE (or 0) as the fourth argument whenever you match codes, names or IDs. Keep TRUE for sorted bands like commission tiers, which is exactly what it was designed for.
2. The value really isn't there
Sometimes #N/A is telling the truth. The code may be mistyped, discontinued, or from a different supplier's list.
Fix: copy the code from the order and use Find, Ctrl+F (Windows) or Cmd+F (Mac), to search the price list. If Find can't see it either, the problem is the data, not the formula. If Find does see it, keep reading, because one of the next two causes is likely.
3. Numbers stored as text
This one catches people with numeric codes, such as 1001, 1002, 1003. To you they look the same. To Excel, the number 1001 and the text "1001" are different values, so the lookup fails with #N/A.
It often happens when data is pasted from an accounting system, a website or a CSV export. Signs to look for: numbers sitting on the left of the cell instead of the right, or a small green triangle in the corner.
Fix: select the cells with the triangle, click the warning icon and choose Convert to Number. If you can't change the source data, convert inside the formula instead. If the table holds real numbers but your lookup cell holds text, use =VLOOKUP(VALUE(E2),$A$2:$C$6,3,FALSE). If it's the other way round, use =VLOOKUP(E2&"",$A$2:$C$6,3,FALSE) to turn the number into text.
4. Extra spaces you can't see
"P200" and "P200 " look identical on screen. The second has a trailing space, and VLOOKUP treats them as different. Spaces sneak in from copied emails, exports and quick typing.
Fix: to clean the value you're looking up, wrap it in TRIM:
=VLOOKUP(TRIM(E2),$A$2:$C$6,3,FALSE)
If the spaces are in the price list itself, add a helper column with =TRIM(A2), fill it down, then copy it and paste as values over the original codes. A quick test: =LEN(A3) returns 4 for "P200" and 5 if a space is hiding there.
5. The table range moved when you filled down
The first row works. Further down, some rows show #N/A or the wrong item.
Click into one of the lower cells and look at the formula bar. If you see A5:C9 instead of A2:C6, the range slid down as you copied, and the top of the list fell out of it.
Fix: lock the table with dollar signs, $A$2:$C$6. Click inside the range in the formula bar and press F4 (Windows) or Cmd+T (Mac), then fill down again with Ctrl+D (Windows) or Cmd+D (Mac).
6. The column number points at the wrong column
The third argument is a count from the left edge of your table, not the column letter on the sheet. If your table starts in column B, then column D is 3, not 4.
There's a sneakier version too. Someone inserts a "Supplier" column between Item and Price. Your formula still says 3, so it now returns the supplier name instead of the price. If the new column holds numbers, you might not notice for weeks.
Fix: recount the columns after any change to the table. For a more robust formula, let MATCH find the column for you:
=VLOOKUP(E2,$A$2:$D$6,MATCH("Price",$A$1:$D$1,0),FALSE)
Or switch to XLOOKUP or INDEX and MATCH, which point at the price column directly.
7. You're trying to look left
VLOOKUP only searches the first column of the table and returns values to the right. If Aisha has the item name and wants the code, VLOOKUP can't do it, because Code sits to the left of Item. Rearranging the table often isn't an option either.
Fix: use INDEX and MATCH. MATCH finds the row, and INDEX returns the value from any column you choose:
=INDEX($A$2:$A$6,MATCH(G2,$B$2:$B$6,0))
With "Stapler" in G2, MATCH finds it in position 3 of the Item column, and INDEX returns position 3 of the Code column: P300. The 0 at the end of MATCH means exact match, just like FALSE in VLOOKUP. Leave it out and MATCH defaults to approximate match, the same trap as cause 1.
A note on hiding #N/A
It's tempting to wrap everything in IFERROR so the sheet looks tidy:
=IFERROR(VLOOKUP(E2,$A$2:$C$6,3,FALSE),"Check code")
That's fine for a finished report, as long as you show a message rather than 0 or a blank. A blank price can slip through to an invoice. Only add IFERROR once the lookup works, otherwise you hide the clue that tells you what's wrong. If you only want to catch missing codes, IFNA does the same job but leaves other errors visible.
Quick checklist
When a lookup misbehaves, check in this order:
- Does the formula end with FALSE?
- Is the value actually in the list?
- Are the numbers stored as numbers?
- Are there stray spaces?
- Is the table range locked with dollar signs?
- Is the column number still right?
- Does the answer sit to the left of the lookup column?
Practise the fixes
The best way to remember these is to make the mistakes on purpose in a safe place.
Lesson 22, VLOOKUP (exact match) drills the FALSE habit and locked ranges. Lesson 23, VLOOKUP for bands shows you when approximate match is the right choice, using a sorted commission table. Lesson 25, INDEX and MATCH covers lookups to the left. Each one runs in your browser and checks your answer the moment you press Enter. Free, no sign-up.
ExcelyourTraining is not affiliated with Microsoft. Excel is a trademark of Microsoft Corporation.