Start free
Lookup & reference

XLOOKUP function

XLOOKUP looks for a value in one range and returns the matching item from another. It replaces VLOOKUP and INDEX/MATCH: it looks left or right, it finds exact matches by default, and it can say what to show when nothing is found.

Available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web
On this page

XLOOKUP syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
ArgumentRequiredWhat it means
lookup_valueYesWhat you're looking for, usually a cell such as E2.
lookup_arrayYesThe single column or row to search in.
return_arrayYesThe column or row to bring back a value from. Same height as lookup_array.
if_not_foundNoWhat to show when there's no match. Without it you get #N/A.
match_modeNo0 exact (the default), -1 exact or next smaller, 1 exact or next larger, 2 wildcards.
search_modeNo1 searches first to last (the default), -1 last to first.

Examples

Find a price by product code

The code to find is in E2. XLOOKUP searches the codes in column A and returns the price on the same row from column C.

F2=XLOOKUP(E2,A2:A6,C2:C6)
RowABCDEF
1CodeProductPriceFindPrice
2A-101Keyboard$49.00A-103$189.00
3A-102Mouse$19.00
4A-103Monitor$189.00
5A-104Webcam$59.00
6A-105Headset$79.00
=XLOOKUP(E2,A2:A6,C2:C6) → $189.00

Show a message instead of #N/A

A-199 isn't in the list. The fourth argument, if_not_found, decides what appears instead of the #N/A error.

F2=XLOOKUP(E2,A2:A6,C2:C6,"Not found")
RowABCDEF
1CodeProductPriceFindPrice
2A-101Keyboard$49.00A-199Not found
3A-102Mouse$19.00
4A-103Monitor$189.00
5A-104Webcam$59.00
6A-105Headset$79.00
=XLOOKUP(E2,A2:A6,C2:C6,"Not found") → Not found

Look to the left

VLOOKUP can only return columns to the right of the one it searches. XLOOKUP takes any return range, so finding the code for a product name, one column to the left, is the same formula shape.

F2=XLOOKUP(E2,B2:B6,A2:A6)
RowABCDEF
1CodeProductPriceFindCode
2A-101Keyboard$49.00WebcamA-104
3A-102Mouse$19.00
4A-103Monitor$189.00
5A-104Webcam$59.00
6A-105Headset$79.00
=XLOOKUP(E2,B2:B6,A2:A6) → A-104

Find the band a number falls in

Commission rates start at each threshold in column A. With match_mode -1, XLOOKUP returns the exact match or the next smaller threshold, so sales of 32,500 get the rate that starts at 25,000. The thresholds don't need sorting.

E2=XLOOKUP(D2,A2:A5,B2:B5,,-1)
RowABCDE
1Sales fromRateSalesRate
202%32,5006%
310,0004%
425,0006%
550,0008%
=XLOOKUP(D2,A2:A5,B2:B5,,-1) → 6%

Practise it

New data, so you can't copy the answer above. We check the number your formula returns, then change the data to make sure it still holds.

Your task: In F2, return the department of the employee whose ID is in E2.

Graded live
RowABCDEF
1IDNameDepartmentIDDepartment
21041Ana KolaFinance1077
31052Ben OrtizSales
41063Chloe ParkMarketing
51077Dev ShahOperations
61089Eva LindSales
71094Femi AdeFinance

Write the formula in the bar above, then press Check or Enter.

Hint

Search the IDs in A2:A7 for the value in E2, and return from the department column, C2:C7.

Solution

=XLOOKUP(E2,A2:A7,C2:C7) Any formula that returns the same result passes.

Common mistakes

  1. Ranges of different sizes. A2:A6 and C2:C7 don't line up, so XLOOKUP returns #VALUE!. Make both ranges start and end on the same rows.
  2. Expecting a blank instead of #N/A. With no match and no if_not_found, the result is #N/A. Add a fourth argument, such as "" or "Not found".
  3. Ranges that move when you copy the formula down. Copy =XLOOKUP(E2,A2:A6,C2:C6) one row down and the ranges become A3:A7 and C3:C7. Lock them with $: $A$2:$A$6.
  4. Using it where it doesn't exist. Excel 2019 and older show #NAME? for XLOOKUP. If your file must open there, use INDEX and MATCH instead.

XLOOKUP vs VLOOKUP and INDEX/MATCH

XLOOKUP VLOOKUP INDEX + MATCH
Default match Exact Approximate (unless you add FALSE) Depends on MATCH’s last argument
Return column to the left Yes No Yes
Survives inserted columns Yes No, the column number goes stale Yes
Built-in “not found” value Yes No, wrap it in IFNA No, wrap it in IFNA
Works in Excel 2019 and older No Yes Yes

If everyone who opens the file has Microsoft 365 or Excel 2021, use XLOOKUP. If not, INDEX and MATCH does the same job everywhere.

FAQ

Is XLOOKUP better than VLOOKUP?

For most lookups, yes. It finds exact matches by default, can return columns to the left, doesn't break when you insert a column, and has a built-in if_not_found. VLOOKUP is still worth knowing because older files and older Excel versions use it.

Is XLOOKUP case-sensitive?

No. XLOOKUP treats a-103 and A-103 as the same value. For a case-sensitive match, combine XLOOKUP with EXACT, for example =XLOOKUP(TRUE,EXACT(A2:A6,E2),C2:C6).

Can XLOOKUP return more than one column?

Yes. Give it a return range several columns wide, such as B2:C6, and the result spills into the cells to the right. In Excel 365 and 2021 that happens automatically.

Why does XLOOKUP return #NAME?

Either the function name is misspelt or your Excel version doesn't have XLOOKUP. It's in Microsoft 365, Excel 2021 and later, and Excel for the web.

Guides that use XLOOKUP

Worked problems with practice sheets.

Interview prepPractice sheet

Excel lookup interview question: match two tables

The lookup task almost every Excel interview includes: bring a value across from a second table. The answer interviewers want, why VLOOKUP fails here, and a sheet that grades yours.

4 min read · Updated
Errors & fixesPractice sheet

#NAME? error in Excel: what it means and how to fix it

#NAME? means Excel doesn't recognise a word in your formula: a misspelt function, text without quotes, a missing colon. Find it and fix it, with a practice sheet.

2 min read · Updated

Know XLOOKUP? Prove it on a real sheet.

Practise XLOOKUP and the functions around it in a live grid that grades your result and explains your mistakes.

Runs in your browser · Graded on your result · No install