Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

VLOOKUP and Text: Fix Mismatches and Combine Fields

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

VLOOKUP fails on text more often than on numbers, and the fix is almost always one of three things: the lookup value has stray spaces, the text is stored as a number (or vice versa), or you are trying to match on a partial string. This guide shows how to clean the lookup value, force consistent data types, use wildcards for partial matches, and combine text fields into a single key so VLOOKUP returns the right row. It works in Excel for Microsoft 365, Excel 2021 and 2019, and Google Sheets (where VLOOKUP exists but some functions differ). No add-ins are required.

What You'll Need

  • Excel (Microsoft 365, 2021, or 2019) or Google Sheets. The steps below use Excel; Google Sheets equivalents are noted where they differ.
  • A source table with the lookup column on the left and the return column to its right. VLOOKUP cannot look to the left.
  • Your lookup values in a separate column or cell.
  • Optional but helpful: a helper column for cleaned or combined text.

Step-by-Step

  1. Confirm the lookup column is the leftmost column of the source range. If your match column sits to the right of the value you want, VLOOKUP will not work. Either rearrange the source table or use INDEX and MATCH instead. This is the single most common structural mistake.
  2. Clean stray spaces from the lookup value. Extra spaces at the start or end of text are invisible but break exact matches. In a helper cell, wrap the lookup value in TRIM: =TRIM(A2). Then use that helper cell as the VLOOKUP lookup value. TRIM removes leading, trailing and repeated internal spaces in Excel. If spaces are non-breaking (common when data is pasted from web pages), TRIM alone may not remove them; use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) to convert non-breaking spaces to normal spaces first.
  3. Make the data types match. A number stored as text (for example, an employee ID like "00123" or a phone number) will not match a true number. Check by selecting the column and looking at the alignment: text is left-aligned by default, numbers right-aligned. Convert one side to match the other. To convert text-that-looks-like-a-number to a real number, use =VALUE(A2) or multiply by 1 in a helper column. To convert a number to text, use =TEXT(A2,"0") or concatenate with an empty string: =A2&"". Apply the same conversion to the lookup value and to the source column, or use a helper column on the source side.
  4. Use exact match (FALSE or 0) for text lookups. The fourth argument of VLOOKUP controls match type. Use =VLOOKUP(TRIM(A2),Source!$A$2:$D$100,3,FALSE). Omitting the fourth argument or using TRUE assumes the first column is sorted and returns an approximate match, which is almost never what you want with text.
  5. For partial matches, use wildcards. If you want to find a row where the source text contains a word or code, build a wildcard pattern: =VLOOKUP("*"&A2&"*",Source!$A$2:$D$100,3,FALSE). The asterisk matches any number of characters; the question mark matches a single character. Wildcards work in Excel and in Google Sheets when exact match is used. If your data literally contains asterisks or question marks, precede them with a tilde (~) to treat them as normal characters.
  6. Combine multiple text fields into one key. When the match depends on two columns (for example, first name and last name, or product and region), create a helper column on both the source sheet and the lookup sheet: =A2&"|"&B2. Use a separator that does not appear in the data, such as a pipe character. Then VLOOKUP on the combined key. Keep the separator identical on both sides, including spacing.
  7. Wrap the whole formula in IFERROR for clean output. Text mismatches often produce #N/A. Use =IFERROR(VLOOKUP(...),"Not found") so the sheet stays readable. Do not use IFERROR to hide a real problem; check a few #N/A results manually first to confirm they are genuinely missing, not just mismatched.
  8. Lock the source range with absolute references. Press F4 after selecting the range to add dollar signs, so the range does not shift when you copy the formula down. In Google Sheets, the same F4 shortcut works on desktop.

Common Mistakes

  • Leaving the fourth argument out. VLOOKUP then defaults to approximate match and returns wrong rows on unsorted text.
  • Mismatched data types. "1001" as text will not match 1001 as a number. Check alignment and convert one side.
  • Invisible spaces. Pasting from emails, PDFs or web pages often brings trailing spaces or non-breaking spaces. TRIM and SUBSTITUTE fix most cases.
  • Wildcards in the source data. If the source column contains literal asterisks, wildcard lookups behave unexpectedly. Escape them with a tilde.
  • Different separators in combined keys. One side uses a space, the other a pipe. The keys look similar but never match.
  • Case sensitivity expectations. VLOOKUP is not case-sensitive. "apple" and "Apple" match. If you need case-sensitive matching, use EXACT inside an array formula or XLOOKUP with a case-sensitive option where available.

Tips

  • Use XLOOKUP instead of VLOOKUP where available. It looks in any direction, defaults to exact match, and handles text the same way. In Excel for Microsoft 365 and Excel 2021 it is built in; in older versions it is not available.
  • Keep a "clean" copy of your source data and do all TRIM and type conversion in helper columns, so the original stays intact.
  • Use Data > Text to Columns or Power Query to split and clean text in bulk rather than editing cell by cell.
  • Name your source range (Formulas > Define Name) so formulas read clearly and ranges do not drift.
  • Test with a known match and a known non-match before filling the formula down a whole column.

Troubleshooting

  • All results are #N/A. Check the data type on both sides first, then TRIM the lookup value. Confirm the source range includes the row you expect.
  • Some results are #N/A and some are not. This usually points to stray spaces or mixed data types in specific rows. Sort or filter the source column and inspect the failing rows.
  • Wrong row returned. The fourth argument is probably missing or TRUE. Change it to FALSE.
  • #REF! error. The column index number is larger than the number of columns in the range. Count the columns in the source range and adjust.
  • Wildcard lookup returns the first match only. That is how VLOOKUP works; it stops at the first hit. If you need all matches, use FILTER (Excel 365 and Google Sheets) instead.
  • Formula works on one sheet but not another. Check that the source range is on the expected sheet and that absolute references are correct.

Frequently Asked Questions

Why does VLOOKUP return #N/A when the text looks identical?

Almost always a hidden space, a non-breaking space, or a data type mismatch. Wrap the lookup value in TRIM and check whether the source column is stored as text or as numbers.

Can VLOOKUP match part of a text string?

Yes, by using wildcards: put asterisks around the lookup value, for example "*"&A2&"*". Exact match (FALSE) must be used.

Is VLOOKUP case-sensitive?

No. "Apple" and "apple" are treated as the same value. For case-sensitive matching, use EXACT in an array formula or a case-sensitive lookup function where your version supports it.

How do I look up on two columns at once?

Create a helper column on both sheets that joins the two fields with a separator, such as =A2&"|"&B2, then VLOOKUP on the combined key.

Does VLOOKUP work the same in Google Sheets?

The syntax is the same and wildcards work with exact match. Google Sheets also has XLOOKUP and FILTER, which are often better choices for text lookups.

Can I use VLOOKUP to return text instead of numbers?

Yes. VLOOKUP returns whatever is in the target column, including text. Just make sure the column index points to the text column and the fourth argument is FALSE.