Skip to content
TECHNOARTH IT for offices and small businesses.
Software

VLOOKUP returns #N/A but the value is there: how to fix it

VLOOKUP returns #N/A even though the code is in the table? Find the invisible difference (a space, a number stored as text, approximate match) and fix it for good.

VLOOKUP returns #N/A but the value is there: how to fix it

VLOOKUP looks for a value in the first column of a range and returns what’s in another column of the same row. #N/A is its way of saying “I didn’t find it”. In an office this typically happens with an orders sheet that matches codes against a product list exported from the business system: on screen the two codes look identical, but to Excel they aren’t. Before rewriting the formula, find out what the difference is — the rest of this article follows that order.

Spreadsheet with VLOOKUP returning #N/A: a code with an extra space and a missing code highlighted, and the formula with FALSE highlighted
Two classic #N/A cases: a code with a trailing space — left-aligned because it became text (1) — and a code that isn’t in the table (2). The formula uses FALSE for an exact match (3).
In this article
  1. First, find out why Excel thinks they’re different
  2. 1. Spaces and invisible characters
  3. 2. A number on one side, text on the other
  4. 3. The fourth argument was left empty
  5. 4. A wrong range, or one that “moved”
  6. 5. An asterisk or question mark in the lookup value
  7. The value really isn’t there
  8. VLOOKUP between files in a network folder
  9. When to switch to XLOOKUP
  10. Frequently asked questions

First, find out why Excel thinks they’re different

Pick a row that returned #N/A, locate in the table the code that should have been found, and run two checks in an empty column:

  1. Compare the two cells directly, for example =A3=D5. If the result is FALSE, there’s a difference you can’t see.
  2. Count the characters in each one with =LEN(A3) and =LEN(D5). Different lengths point to a space or a hidden character; equal lengths with a FALSE comparison usually mean a number on one side and text on the other.
Spreadsheet comparing the order code with the catalog code: on row 3 the comparison returns FALSE and the text length is 5 versus 4, revealing an extra space
On row 3 the codes look the same, but the comparison returns FALSE and the length is 5 versus 4 (1): there's an extra character in the order code.

With that diagnosis in hand, go straight to the matching cause.

1. Spaces and invisible characters

Files exported from ERP or invoicing systems, or copied from web pages, very often carry a space at the end of the code. The TRIM function strips spaces from the start and end (and collapses double spaces in the middle):

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

If the problem is in the table’s column rather than in the lookup value, the safest move is to build a helper column with =TRIM(D2), then copy it and paste it as values over the original.

One case is particularly misleading: the non-breaking space (character 160), common in content copied from websites. The official TRIM function page explains that it only deals with the regular space, so the character count stays higher even after cleaning. In that case, replace the character first:

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

2. A number on one side, text on the other

This is the most common cause when one side came from a CSV file. A cell holding a number stored as text is left-aligned and shows a small green triangle in the corner. To fix it:

  1. Select the cells in the problem column.
  2. Click the warning icon that appears next to the selection (or press Alt+Shift+F10).
  3. Choose Convert to Number.

If the green triangle doesn’t appear on any cell, error checking is switched off on that computer. Open File › Options › Formulas and, under Error Checking, check Enable background error checking, as described in Microsoft’s article on numbers stored as text.

Excel Options, Error Checking section, with the Enable background error checking box selected and highlighted
In File › Options › Formulas, this box (1) must be selected for the green triangle and the Convert to Number option to appear.

When you can’t change the source sheet (because the system regenerates it every day, say), adjust inside the formula instead: VALUE(A2) turns text into a number, and A2&"" goes the other way.

3. The fourth argument was left empty

VLOOKUP’s last argument sets the type of match. With FALSE (or 0), it only accepts the exact value. If you leave it blank or use TRUE, Excel runs an approximate match, which assumes the first column is sorted in ascending order; with an unsorted table it returns #N/A or, worse, a wrong value without any warning. When matching customer codes, product codes or tax IDs, always use FALSE. Approximate match only makes sense for band tables, such as commission rates by sales amount.

4. A wrong range, or one that “moved”

  • VLOOKUP only searches the first column of the range you give it. If the code is in column D, the range starts at D, and the column number is counted from there (D = 1, E = 2).
  • Without dollar signs, the range slides down as you drag the formula and leaves the last rows out. Lock it with F4: $D$2:$E$500.
  • New rows added below the end of the range fall outside the search. One alternative is to turn the list into a table (Ctrl+T) and use the table’s name in the formula, which grows with new rows.
  • If the column number is larger than the number of columns in the range, the result is #REF!, not #N/A — see Excel errors explained.

5. An asterisk or question mark in the lookup value

In VLOOKUP, * and ? act as wildcards, according to the official function documentation. A code such as KIT*2 can match the wrong item. To search for the character literally, put a tilde in front of it: KIT~*2.

The value really isn’t there

Sometimes #N/A is correct: the new customer simply hasn’t been added yet. To keep the report readable, swap the error for a message. Prefer IFNA, which only hides #N/A, over IFERROR, which would also hide a #REF! caused by a broken formula:

=IFNA(VLOOKUP(A2,$D$2:$E$500,2,FALSE),"Not found")

VLOOKUP between files in a network folder

It’s common for an orders workbook to pull data from a list kept in a shared folder on the server or NAS. That works, but the link stores the path to the source file. If a colleague opens the workbook on a PC where the network drive has a different letter, or someone renames or moves the list, the results stop updating or turn into errors. Use the same drive letter on every machine — the walkthrough is in how to map a network drive — and, to repair a link that’s already broken, open the Workbook Links pane on the Data tab (in older versions the command is called Edit Links) and use Change source to point to the right file.

When to switch to XLOOKUP

XLOOKUP removes three of VLOOKUP’s limitations in one go: it searches any column (including ones to the right of the result), it uses exact match by default, and it has its own argument for the “not found” text:

=XLOOKUP(A2,$E$2:$E$500,$D$2:$D$500,"Not found")
Spreadsheet with XLOOKUP searching the code in column E and returning the product from column D; code 1007, which doesn't exist, shows Not found
XLOOKUP (1) searches column E (2) and returns column D, which is to its left — VLOOKUP can't do that. When the code doesn't exist, the 4th argument's text (3) appears instead of #N/A.

The catch is compatibility. The XLOOKUP function page states that it isn’t available in Excel 2016 or Excel 2019. If the office still has machines running those versions, a workbook using XLOOKUP won’t work on them.

SituationBest choice
Everyone uses Microsoft 365 or Excel 2021/2024XLOOKUP
Any PC with Excel 2016 or 2019VLOOKUP with FALSE
Result column to the left of the lookup column, no XLOOKUPINDEX with MATCH

Frequently asked questions

VLOOKUP works on my computer but gives #N/A on my colleague’s.

If the formula pulls the list from another file, start with the link: the source path may not exist on their PC (a different drive letter, or no access to the folder), and then the results don’t update or become errors. Open the source file on both computers through the same path and check the workbook links. If the list is in the same workbook, repeat the diagnosis with =A3=D5 and LEN on their PC.

I fixed the spaces and #N/A is still there.

Compare the lengths again with LEN. If there’s still a difference, there’s a non-breaking space or another hidden character; use SUBSTITUTE with CHAR(160). If the lengths match, the problem is the data type: a number on one side and text on the other.

Can I use whole columns, such as D:E, in the range?

Yes, and new rows are then picked up automatically. Just make sure there’s nothing else below the list in those columns, such as totals or notes, because they become part of the search too.

Share

About the author

TECHNOARTH Editorial Team

The TECHNOARTH newsroom: technology tutorials, guides, comparisons and news produced with AI assistance and checked against manufacturers’ official sources.

Reviewed by Arth Moraes — Arth Moraes is the editorial pen name of the person responsible for TECHNOARTH, who sets the agenda, reviews and approves every tutorial before publication and is accountable for corrections.