Lookup fails because numbers are stored as text
Updated · Checked on a live sheet · Excel and Google Sheets
The most likely fix
Match the lookup value's type to the table's: if the table holds text IDs, look up M1&""; if it holds real numbers, look up VALUE(M1). Converting the whole column once is the cleaner long-term fix.
Fix it yourself
The formula in M2 shows the problem. Edit it to the fixed version and watch the sheet recalculate.
| A | B | C | D | E | F | G | H | I | J | K | L | M | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Order | SKU | Qty | SKU | Product | Price | Stock | Order | 2003 | ||||
| 2 | 2001 | PL-104 | 2 | PL-101 | Fern | $9.50 | 40 | Qty | #N/A | ||||
| 3 | 2002 | PT-210 | 1 | PL-104 | Monstera | $34.00 | 12 | ||||||
| 4 | 2003 | TL-301 | 3 | PL-107 | Snake plant | $22.00 | 25 | ||||||
| 5 | 2004 | PL-101 | 1 | PT-210 | Terracotta pot | $12.50 | 60 | ||||||
| 6 | 2005 | SL-401 | 4 | PT-212 | Ceramic pot | $19.00 | 18 | ||||||
| 7 | 2006 | PL-104 | 1 | TL-301 | Watering can | $18.00 | 9 | ||||||
| 8 | 2007 | PT-212 | 2 | SL-401 | Potting mix | $7.25 | 80 | ||||||
| 9 | 2008 | PL-107 | 1 |
Shows the problem
=VLOOKUP(M1,A2:C9,3,FALSE)Fixed
=VLOOKUP(M1&"",A2:C9,3,FALSE)Causes, most likely first
1The table holds text, the key is a number
Systems that export IDs often write them as text, so the column looks numeric but isn't. A number never equals text in a lookup. Joining an empty string turns the key into text:
M1&"". That's the fix in the sheet above: “2003” the text matches, and the quantity appears.Wrong
=VLOOKUP(M1,A2:C9,3,FALSE)Fixed
=VLOOKUP(M1&"",A2:C9,3,FALSE)2The key is text, the table holds numbers
The reverse: someone typed the key with an apostrophe, or it came from a text formula like LEFT or MID, which always return text. Convert it with
VALUE(M1)(or--M1).Wrong
=VLOOKUP(LEFT(A2,4),$G$2:$H$9,2,FALSE)Fixed
=VLOOKUP(VALUE(LEFT(A2,4)),$G$2:$H$9,2,FALSE)3How to tell which side is text
Put
=ISTEXT(M1)next to the key and=ISTEXT(A2)next to a table value. TRUE means text. Trust ISTEXT and ISNUMBER over appearance: formatting a cell doesn't change what's stored in it.4Fix the column once instead
If you look up the same column often, convert it rather than fixing every formula. In a spare column,
=VALUE(A2)filled down gives real numbers; copy them and paste as values over the original. Then the plain lookup works everywhere. Clean up messy text has the details, including amounts like"$1,250.00".5Codes with leading zeros
Codes like 00417 must stay text: as numbers they become 417 and no longer match the table. If the table holds the codes as text and your key is a number,
TEXT(M1, "00000")rebuilds the leading zeros before the lookup. The TEXT function guide explains the format codes.Wrong
=VLOOKUP(M1,$G$2:$H$9,2,FALSE)Fixed
=VLOOKUP(TEXT(M1,"00000"),$G$2:$H$9,2,FALSE)
Stop it happening again
Decide on one type for each ID column and convert it as soon as data arrives: real numbers for amounts and quantities, text for codes with leading zeros or letters. Converting once beats patching every lookup. When you paste data from another system, check one value with ISTEXT before building formulas on it. If both types really must coexist (an ID column filled by two sources), make the lookup tolerant on purpose and say so in a note next to it. Formatting a column as Number afterwards doesn't convert text that's already there, so re-enter or convert the values.
Questions
Why does Excel show a green triangle on some cells?
That's Excel's error checking, and one of the things it flags is a number stored as text. Its menu offers to convert the cell. Converting a whole column that way works, but the formula fixes on this page are safer when the data is re-imported regularly.
Will multiplying by 1 convert text to numbers?
Yes, arithmetic on text that looks like a number converts it: M1*1 or --M1 give a number, the same as VALUE(M1). Text that doesn't look like a number, such as “n/a”, gives #VALUE! instead.
Which is better: convert the key or the column?
Convert the column when you own the data and use it in several formulas: every lookup then works without tricks. Convert the key inside the formula when the table comes from someone else and gets replaced regularly, so your fix survives the next import.
In Google Sheets
Google Sheets keeps the same distinction between the number 2003 and the text “2003”, and the same fixes work there: &"", VALUE, ISTEXT and ISNUMBER all exist in Sheets. XLOOKUP and MATCH need matching types too, in both apps.
Why this happens
Spreadsheets store a type with every value. Formatting a column as Number after the fact doesn't change text that's already there, which is why imported IDs keep failing even after you change the format. The lookup is doing exactly what it should: comparing values that are, underneath, different. See the #N/A error page for the other causes, and VLOOKUP #N/A when the value exists for spaces.
Sources
Official documentation the facts on this page were checked against.