Excel data cleaning

VLOOKUP Not Working in Excel? Fix #N/A, Hidden Spaces and Text Numbers

By the DecodingPro teamUpdated 4 min read

Quick answer

When VLOOKUP returns #N/A for a value you can see, the two values are almost never identical underneath. The usual causes are a stray space (including the non-breaking kind), a number stored as text on one side only, and a missing FALSE at the end of the formula. Test with =A2=E2 on the two cells: if it says FALSE, they differ, and the steps below show how.

VLOOKUP is exact about what it compares. "1001" as text and 1001 as a number are different things to it, and so are "Smith" and "Smith ". Because they look the same on screen, the failure feels random. It is not: one of the five causes below is almost always behind it.

Step 1: check the two cells really match

Put the lookup value in one cell and the matching value from the table in another, then compare them directly:

=A2=E2

TRUE means they match and the problem is in the formula (see cause 5). FALSE means the data differs even though it looks the same. Next, compare the lengths:

=LEN(A2)    =LEN(E2)

If the lengths differ, there are hidden characters. If they are equal but the comparison is still FALSE, one side is probably a number and the other text.

Cause 1: trailing and leading spaces

A space at the end of "Smith " is invisible. Remove it from the lookup column and from the table:

=TRIM(A2)

Fill down, copy, and Paste Special, Values, over the original. Do this on both sides, because the stray space can be in either place. The guide on removing extra spaces in Excel covers every variant.

Cause 2: non-breaking spaces

Data copied from a web page or PDF often contains character 160, which looks like a space but which TRIM does not touch. If TRIM changed nothing and the lengths still differ:

=TRIM(SUBSTITUTE(A2,CHAR(160)," "))

Cause 3: numbers stored as text

If one column holds the number 1001 and the other the text "1001", VLOOKUP will not match them. Signs: a green triangle in the corner of the cell, numbers aligned to the left, or =ISNUMBER(A2) returning FALSE. To convert text to numbers:

=VALUE(TRIM(A2))

Or the other way round, to turn the numbers into text so both sides are text: =A2&"". Pick one type and make both columns the same. The full method is in converting text to numbers in Excel.

Warning: do not convert IDs, phone numbers or postcodes to numbers just to make a lookup work. Leading zeros would be lost. Convert the other side to text instead.

Cause 4: the lookup value is not in the first column

VLOOKUP only searches the first column of the table you give it and returns a value to the right. If the value you search for sits in the second column, the result is #N/A. Either move the search column to the left, or use INDEX and MATCH, or XLOOKUP if your Excel has it, which can look in any column.

Cause 5: the formula itself

Check the last argument. Without it, VLOOKUP assumes an approximate match, which only works on sorted data and returns wrong or missing results otherwise. For an exact match, always end with FALSE:

=VLOOKUP(A2,$E$2:$G$500,2,FALSE)

Also lock the table range with dollar signs. If the range slides down as you fill the formula, the bottom rows silently search a smaller and smaller table.

A quick checklist

SymptomLikely causeFix
Looks identical, comparison is FALSEHidden spaceTRIM, then SUBSTITUTE with CHAR(160)
Green triangle, left-aligned numbersNumber stored as textVALUE, or make both sides text
Works for the first rows, fails further downTable range not lockedUse $E$2:$G$500
Wrong results, not #N/AApproximate matchAdd FALSE as the last argument
Always #N/A for one columnSearch column is not the firstINDEX and MATCH, or XLOOKUP

Clean both lists before you look anything up

Most VLOOKUP trouble is dirty data, not a formula mistake. DecodingPro trims every text cell (including non-breaking spaces), turns text that is really a number into a real number, and logs every change, so two lists that should match actually do. Run both lists through first and the lookup usually works without touching the formula.

Try it on your own file

You start with 100 free credits. Every change is logged, and anything unclear is flagged, never guessed.

Fix a spreadsheet

Questions people ask

Why does VLOOKUP return #N/A when the value exists?

The two values are not identical underneath. The most common reasons are a trailing or non-breaking space, a number stored as text on one side, or a missing FALSE for exact match. Compare the cells with =A2=E2 to confirm.

Does TRIM fix every hidden space?

No. TRIM removes the ordinary space only. Spaces copied from web pages are often character 160, which needs SUBSTITUTE(A2,CHAR(160)," ") before TRIM.

Should I use XLOOKUP instead of VLOOKUP?

If your version of Excel has XLOOKUP, it is easier: it defaults to exact match and can search any column. It still fails on hidden spaces and text numbers, so cleaning the data comes first either way.

How do I stop #N/A from showing in my results?

Wrap the formula in IFERROR, for example =IFERROR(VLOOKUP(A2,$E$2:$G$500,2,FALSE),"not found"). Do this after fixing the data, because IFERROR also hides real problems you would want to see.

Keep reading

01Excel data cleaningHow to Clean Messy Excel Data: A Step-by-Step GuideThe fixed order that stops one fix from undoing another, with the formulas for every step.10 min read02Text and numbersHow to Keep Leading Zeros in Excel and CSV (ZIP Codes, IDs)Why Excel turns 02134 into 2134, how to get the zeros back, and how to stop it happening when you open a CSV.5 min read03CSV and importsHow to Clean a CSV File Before Importing It Into a CRMSeven fixes that prevent duplicate contacts, rejected rows and scrambled characters, and the 10-row test to run first.4 min read04DatesHow to Fix Dates in Excel and CSV Files (Mixed Formats)Text dates, day-month swaps, two-digit years and the one rule that makes dates safe to share.8 min read05Phone numbersHow to Fix Phone Numbers in Excel: Format and Country CodesLeading zeros, 9.19E+11, country codes and the international format that every system accepts.6 min read06DuplicatesHow to Remove Duplicates in Excel Without Losing DataExact, near and partial duplicates: decide what counts, mark before you delete, keep the best record.6 min read07DuplicatesHow to Find and Highlight Duplicates in ExcelFind repeats safely first: highlight them, count them, keep the first one, and spot the near-duplicates Excel does not see.3 min read08NamesHow to Standardize Names in Excel: Proper Case and ExceptionsWhat PROPER gets wrong, how to protect names that are already right, and how to flip "Smith, John" into "John Smith".4 min read09Email addressesHow to Fix Email Typos in Excel: gmial.com, .con and Missing @The typos that make campaigns bounce, and the formulas and checks that fix them without guessing.4 min read10Email addressesHow to Clean an Email List Before You Send a CampaignA five-step routine that removes the avoidable bounces from a list without deleting anyone you should keep.3 min read11NamesHow to Split Full Names into First and Last Name in ExcelFlash Fill, Text to Columns and formulas for splitting names, and the names that trip each one up.4 min read12Text cleanupHow to Remove Extra Spaces in Excel (TRIM, CLEAN and Non-Breaking Spaces)Why TRIM sometimes does nothing, and the one formula that removes every kind of stray space.3 min read13Text cleanupHow to Remove Special Characters and Line Breaks in ExcelThe characters you cannot see, the smart quotes you can, and the exact formula or shortcut that removes each one.4 min read14NumbersHow to Convert Text to Numbers in Excel (Numbers Stored as Text)Why sums show zero, why numbers sit on the left, and four ways to turn text back into real numbers.3 min read15Excel data cleaningHow to Clean Data with Power Query in Excel (Step by Step)Record your cleaning steps once and replay them on every new file, without formulas and without touching the original data.4 min read16Comparing dataHow to Compare Two Lists in Excel and Find What Is MissingFind the names, IDs or emails that are in one list and not the other, with formulas that scale.3 min read17CSV and importsFix Garbled Characters and Broken CSV Imports (UTF-8)UTF-8, delimiters, leading zeros, quotes and a checklist that makes a file safe to import.7 min read18Data entryData Entry Accuracy: How to Check, Measure and Improve ItWhat the research says about error rates, why proofreading fails and the checks that actually work.9 min read20Excel data cleaningHow to Remove Blank Rows in Excel (Fast, Without Deleting Real Data)Delete hundreds of empty rows in seconds, and learn why a row that looks blank sometimes is not.4 min read21Email addressesHow to Validate Email Addresses in Excel (Formulas, Typos and What They Miss)A formula that flags broken addresses, how to catch gmial.com-type typos, and the limit of any check done in a spreadsheet.5 min read22Excel data cleaningHow to Find and Fix Typos in an Excel Column (Cities, Names, Categories)Spot Bostn next to Boston in a column of thousands, and fix the typos without touching values that are merely similar.5 min read