Smart Systems for Home

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

Excel Lookup Values in a Table: VLOOKUP & XLOOKUP

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

Yes, Excel can pull a value from a table automatically based on a match, and the fastest way is the VLOOKUP or XLOOKUP function. You give Excel a value to find (like a product code), tell it where to look, and it returns the related value (like a price) from the same row. You need no special setup, just a table of data and a cell to hold your lookup value. VLOOKUP works in every Excel version; XLOOKUP is available in Microsoft 365 and Excel 2021 and later.

What You'll Need

  • Excel (any version for VLOOKUP; Microsoft 365, Excel 2021 or Excel for the web for XLOOKUP)
  • A table of data where each row is one record, such as codes in column A and prices in column B
  • A cell where you type or paste the value you want to look up

Step-by-Step

The steps below use an example where codes sit in A2:A50 and prices in B2:B50, and you type the code you want into cell E2. Adjust the cell references to your own sheet. Exact labels and button positions can differ slightly between Excel for Windows, Mac and the web, but the formulas are identical.

Method 1: VLOOKUP (works in every version)

  1. Type the value you want to find into cell E2 (for example, a product code).
  2. Click the cell where you want the answer, such as F2.
  3. Type the formula: =VLOOKUP(E2,A2:B50,2,FALSE)
  4. Press Enter. The formula searches the first column of A2:B50 for the value in E2 and returns the value from column 2 of that range (the price).
  5. Press F4 on the range reference while editing if you plan to copy the formula down, so A2:B50 becomes $A$2:$B$50 and the range stays fixed.
  6. To wrap errors neatly, use =IFERROR(VLOOKUP(E2,$A$2:$B$50,2,FALSE),"Not found") so missing matches show your message instead of #N/A.

Method 2: XLOOKUP (Microsoft 365 and Excel 2021+)

  1. Type your lookup value into E2.
  2. Click the result cell and type =XLOOKUP(E2,A2:A50,B2:B50,"Not found")
  3. Press Enter. XLOOKUP searches A2:A50 for the E2 value and returns the matching item from B2:B50. It finds exact matches by default, so there is no FALSE argument to worry about.
  4. To copy the formula down a column, select the cell, then drag the fill handle (the small square at the bottom-right of the cell) down over the other cells. Add dollar signs ($A$2:$A$50) first so the lookup columns stay fixed.

Method 3: INDEX and MATCH (flexible, works in all versions)

  1. Use =INDEX(B2:B50,MATCH(E2,A2:A50,0)) in your result cell.
  2. Press Enter. MATCH finds the row number of the value in E2 inside A2:A50 (the 0 means exact match), and INDEX returns the value from that row in B2:B50.
  3. This method can look left as well as right, which VLOOKUP cannot.

Common Mistakes

  • Forgetting FALSE (or 0) in VLOOKUP. Without it Excel does an approximate match and can silently return the wrong row.
  • Not locking the table range. Copying the formula without $ signs shifts the range and breaks the lookup.
  • Looking up a value that is not in the first column of the range. VLOOKUP only searches the leftmost column of the range you give it.
  • Number stored as text. A code typed as text will not match a number in the table, producing #N/A even though the value looks identical.
  • Hidden spaces. Trailing spaces in either the lookup value or the table cause failed matches; use TRIM to clean them.
  • Counting the return column from the range, not from the sheet. If your range starts at column B, column 1 of the range is B, not A.

Tips

  • Convert your data to a real Excel table (select it, then Insert > Table) and use its name in the formula, like =VLOOKUP(E2,Products,2,FALSE). The range then grows automatically when you add rows.
  • XLOOKUP can search in any direction and return multiple columns at once, so prefer it if your Excel version has it.
  • Use TRUE as the last VLOOKUP argument only for approximate matches on sorted data, such as tax brackets or commission tiers.
  • For fuzzy matching (misspelled names), consider the Fuzzy Lookup add-in or Power Query merge rather than guessing with formulas.
  • Double-click the fill handle instead of dragging to fill the formula down to the last row of neighbouring data instantly.

Troubleshooting

  • #N/A: the value was not found. Check for typos, extra spaces (try =TRIM(E2)), and number-versus-text mismatches (a green triangle in the cell means a number stored as text). Wrap the formula in IFERROR to handle it gracefully.
  • #REF!: the column index is larger than the number of columns in the range. Count your range's columns and fix the number.
  • #VALUE!: check that your lookup cell actually contains a value and that text criteria are quoted.
  • Wrong result rather than an error: you likely left out FALSE in VLOOKUP, so Excel returned an approximate match.
  • XLOOKUP shows #NAME?: your Excel version does not support XLOOKUP. Use VLOOKUP or INDEX/MATCH instead, or update Microsoft 365.
  • Formula returns 0 for an empty matched cell: that is expected; wrap with a check like =IF(result="","",result) to show blank instead.

Frequently Asked Questions

What is the difference between VLOOKUP and XLOOKUP?

XLOOKUP is newer and more flexible: it defaults to exact matches, can look in any direction, and can return multiple columns. VLOOKUP only searches the leftmost column of the range and needs FALSE for an exact match.

Can VLOOKUP look to the left?

No. VLOOKUP can only return values to the right of the lookup column. Use XLOOKUP or INDEX/MATCH to return values from columns to the left.

How do I look up a value based on two criteria?

With XLOOKUP you can concatenate criteria: =XLOOKUP(E2&F2,A2:A50&B2:B50,C2:C50,"Not found"). In older Excel, add a helper column joining the two fields and look that up.

Is the lookup case-sensitive?

No. VLOOKUP, XLOOKUP and MATCH treat "abc" and "ABC" as the same unless you add the case-sensitivity argument in XLOOKUP (the fifth argument, set to 1) or use EXACT with array formulas.

Why does my lookup work in one row but not when I copy it down?

Your range references are shifting. Edit the formula and press F4 on the table range to make it absolute ($A$2:$B$50) before copying.

Can I do lookups across two different sheets?

Yes. Include the sheet name in the range: =VLOOKUP(E2,Sheet2!A2:B50,2,FALSE). If the sheet name contains spaces, wrap it in single quotes: 'Price List'!A2:B50.