formulastreak

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.

Column A holds order numbers as text, M1 holds the number 2003 · edit M2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultM2 = #N/A
ABCDEFGHIJKLM
1OrderSKUQtySKUProductPriceStockOrder2003
22001PL-1042PL-101Fern$9.5040Qty#N/A
32002PT-2101PL-104Monstera$34.0012
42003TL-3013PL-107Snake plant$22.0025
52004PL-1011PT-210Terracotta pot$12.5060
62005SL-4014PT-212Ceramic pot$19.0018
72006PL-1041TL-301Watering can$18.009
82007PT-2122SL-401Potting mix$7.2580
92008PL-1071

Shows the problem

=VLOOKUP(M1,A2:C9,3,FALSE)

Fixed

=VLOOKUP(M1&"",A2:C9,3,FALSE)

Causes, most likely first

  1. 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)
  2. 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)
  3. 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.

  4. 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".

  5. 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.

Practise this in 5 minutes

VALUE is taught in Lesson 32: Numbers stored as text (Unit 8, Cleaning text at scale), on a live sheet with instant feedback. Pro

Open “Numbers stored as text”

Get the formulastreak newsletter

Bite-sized formula tips you can use at work the next day, plus a heads-up when new free tools and lessons land. It arrives now and then, never in a flood.

No spam, unsubscribe in one click. We store your email, this consent and when you gave it. Details in our privacy policy.

Need a quick reference? The formula cheat sheet is free to read and print.