Function Problems

Fix Excel VLOOKUP Errors Caused by Text and Number IDs

Steven ParkerSteven Parker Nov 12, 2026 868 views

Question details

The user needs to fix VLOOKUP errors caused by lookup IDs being stored as text in one column and numbers in another.

Fix Excel VLOOKUP Errors Caused by Text and Number IDs
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user is matching IDs between two tables with VLOOKUP or XLOOKUP, including IDs that may contain leading zeros.
Observed behavior
The lookup returns an error or no match even though the displayed IDs appear to be the same.
Before you start

Check the formula bar for a few IDs in both lookup columns to confirm whether they are text or numbers. Custom number formatting changes only the display and does not change the stored data type used by VLOOKUP.

Solution 1Recommended

Convert both lookup ID columns to the same data type

Use this method when IDs should be treated as numeric values or when the source data contains text-formatted numbers.

VLOOKUP requires the lookup value and the matching values to be comparable. A text value such as "123" is not the same as the number 123, even if both cells display 123.

1
Create a cleaned numeric helper column

In an empty column next to the first ID list, enter =VALUE(A2) to convert a text-formatted numeric ID in A2 into a number. Fill the formula down the column.

2
Remove spaces and hidden characters if needed

If imported IDs may include extra spaces or nonprinting characters, use =VALUE(TRIM(CLEAN(A2))) in the helper column, then fill down.

3
Clean the lookup table ID column

Create the same type of helper column beside the ID column in the lookup table, using =VALUE(B2) or =VALUE(TRIM(CLEAN(B2))) as appropriate.

4
Update the lookup formula

Point VLOOKUP to the cleaned helper columns, for example =VLOOKUP(C2,$H$2:$I$100,2,FALSE), where C2 and column H contain the converted numeric IDs.

Convert both lookup ID columns to the same data type
Use exact matching: Use FALSE as the final VLOOKUP argument so Excel returns only an exact ID match.
WPS Spreadsheets solution

Clean ID data and run accurate lookups in WPS Spreadsheets

WPS Spreadsheets lets you standardize text and numeric IDs with helper formulas, remove hidden characters, and use exact-match VLOOKUP or XLOOKUP formulas to return reliable results.

  1. 1. Open the workbook in WPS Spreadsheets: Select Open on the WPS Office home screen and choose the Excel workbook containing the ID columns.
  2. 2. Add a helper column for normalized IDs: Click an empty column beside the IDs and enter =VALUE(TRIM(CLEAN(A2))) for numeric IDs or =TEXT(A2,"0000000000") for fixed-length text IDs.
  3. 3. Fill the helper formula down: Select the formula cell and drag the fill handle down to apply the conversion to all ID rows.
  4. 4. Use the cleaned columns in an exact lookup: Enter a formula such as =XLOOKUP(C2,$H$2:$H$100,$I$2:$I$100,"Not found",0) or use VLOOKUP with FALSE as the final argument.
Use VALUE, TEXT, TRIM, and CLEAN to standardize lookup IDs.Run exact-match VLOOKUP and XLOOKUP formulas for cleaned ID columns.Open, edit, and save Microsoft Excel .xlsx and .xls files with format compatibility.Use a familiar spreadsheet interface for a smooth transition from Excel.
microsoft office alternative - wps office

Frequently Asked Questions

Why does VLOOKUP return #N/A when the IDs look identical?

One ID may be stored as text while the other is stored as a number. Convert both columns to the same type with VALUE for numbers or TEXT for fixed-length text IDs, then run an exact-match lookup.

Does changing a cell to Number format fix a VLOOKUP type mismatch?

No. Number formatting changes only the displayed appearance. Use a conversion formula such as =VALUE(A2) or multiply the cell value by 1 to change text-formatted numbers into actual numbers.

How do I keep leading zeros in IDs for VLOOKUP?

Treat the IDs as text. Create matching helper columns with a formula such as =TEXT(A2,"0000000000"), using the correct number of zeros for the ID length, and look up those text values.

How can I remove hidden spaces from imported lookup IDs?

Use =TRIM(CLEAN(A2)) to remove extra spaces and many nonprinting characters. If the ID should be numeric, wrap it in VALUE: =VALUE(TRIM(CLEAN(A2))).

Should I use VLOOKUP or XLOOKUP after cleaning IDs?

Either works when both ID columns have the same data type. XLOOKUP is more flexible because the return column can be anywhere, while VLOOKUP requires the lookup column to be the first column in its selected table range.