Clean & Look UpExtra· 40 min read

Lookups: VLOOKUP & XLOOKUP

Lookups find a value in one table and pull back matching information — like a search that returns an answer.

What you will learn

  • Explain what a lookup does
  • Use VLOOKUP to fetch a matching value
  • Use the simpler, newer XLOOKUP

What a lookup is for

Imagine a price list, and separately a list of orders that only has product names. A lookup searches the price list for each product and brings back its price. It is like asking, “find this item in that table and tell me its price.”

The price-list example

Here is a small price list in columns A and B:

AB
1ProductPrice
2Apples50
3Bananas30
4Cherries90

VLOOKUP: the classic

VLOOKUP (vertical lookup) searches down the first column of a table and returns a value from a column to its right. It needs four parts:

  1. The value to find (for example the product name).
  2. The table to search in (the range).
  3. The column number to return from (1 is the first column of the table, 2 the second, and so on).
  4. Whether you want an exact match — for that, put FALSE.
Find Bananas in the table and return the value from column 2 (the price)
=VLOOKUP("Bananas", A2:B4, 2, FALSE)

Note: Output: 30 VLOOKUP searched column A for Bananas, found it in row 3, then returned the value from the second column of the table, which is the price 30.

Watch out: Always end VLOOKUP with FALSE for an exact match. If you leave it off (or use TRUE), Excel does an approximate match and can return the wrong row. VLOOKUP also cannot look to the left of the search column.

XLOOKUP: the easier, newer way

XLOOKUP does the same job but is simpler and more flexible. You give it three clear parts: what to find, where to look (the lookup column), and what to return (the result column). No counting columns, and it is exact by default.

Find Bananas in column A and return the matching price from column B
=XLOOKUP("Bananas", A2:A4, B2:B4)

Note: Output: 30 XLOOKUP matched Bananas in the lookup range A2:A4 and returned the value in the same position from the result range B2:B4. No column numbers needed, and it matches exactly by default.

VLOOKUPXLOOKUP
You give itvalue, table, column number, FALSEvalue, lookup range, result range
Exact matchYou must add FALSEExact by default
Can look left?NoYes
Easier to read?Trickier (count columns)Yes

When the item is not found: #N/A

If a lookup cannot find what you asked for, it does not stay blank — it shows the error #N/A, which means “not available, I could not find it.” This is normal and expected. To show a friendly message instead, wrap the lookup in IFERROR, which says “try this; if it errors, show that.”

Replace the #N/A error with a clear message of your own
=IFERROR(XLOOKUP("Mango", A2:A4, B2:B4), "Not found")

Note: Output: Not found There is no Mango in the price list, so the lookup returned #N/A. IFERROR caught that error and showed Not found instead — much friendlier in a report than a cryptic #N/A. Works the same way around a VLOOKUP.

Tip: If your Excel has XLOOKUP (Excel 2021 and Microsoft 365, and Google Sheets), prefer it — it is clearer and avoids VLOOKUP’s common traps. Learn VLOOKUP too, because you will still meet it in older sheets.

Q. In =VLOOKUP("Cherries", A2:B4, 2, FALSE), what does the number 2 mean?

Answer: The third part of VLOOKUP is the column number to return from. 2 means the second column of the table range (here, the price).

✍️ Practice

  1. Build the three-row price list above, then use VLOOKUP to fetch the price of Apples.
  2. Do the same lookup with XLOOKUP and confirm you get the same answer.

🏠 Homework

  1. Make a 6-item product/price table and a separate list of 4 order product names. Use a lookup to pull each order’s price next to it.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →