What XLOOKUP does

XLOOKUP finds a value in one column and returns the matching value from another column in the same row, such as the price for a product code or the shipping cost for a country. You give it what to find, the column to search and the column the answer is in, as in =XLOOKUP(B9,A2:A7,C2:C7).

It does the job of the older VLOOKUP with fewer ways to go wrong. The search column and the answer column are two separate ranges, so the answer can sit to the left of the search column, and inserting a column in the table doesn’t break the formula. It looks for an exact match unless you ask for something else, and it can show a message of your choice when nothing matches.

Syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Arguments in square brackets are optional; the rest are required.
lookup_valueRequired
What to find: a product code, a name, a country. Usually a cell such as B9, so the formula follows whatever is typed there.
lookup_arrayRequired
The one column (or row) to search, such as A2:A7.
return_arrayRequired
The column (or row) to bring the answer back from, such as C2:C7. It must be the same size as lookup_array, and it can sit to the left of it.
if_not_foundOptional
What to show when there's no match, like "Not found" or 0. Without it, XLOOKUP shows #N/A.
match_modeOptional
0, an exact match, is the default. -1 and 1 also accept the next smaller or next larger item when there's no exact match, and 2 lets * and ? act as wildcards.
search_modeOptional
1, from the first item to the last, is the default. -1 searches from the bottom up, which finds the last match. 2 and -2 are fast searches for data sorted in ascending or descending order.

The first three arguments are all most lookups need.

Example: find the shipping cost for a country

The shipping table is in A1:C7. A country is typed in B9, and B10 looks up its cost.

XLOOKUP finds Portugal in A2:A7 and returns the cost from the same row of C2:C7. In B10, =XLOOKUP(B9,A2:A7,C2:C7) returns 12.50.

Read it as: find B9 in A2:A7, and return what’s in the same position in C2:C7. Type Spain in B9 and the cost changes to 11.50.

Example: show a message when there’s no match

Norway isn’t in the table. Without the fourth argument the cell would show #N/A. With it, the cell says what happened:

The fourth argument replaces #N/A with a message. In B10, =XLOOKUP(B9,A2:A7,C2:C7,"Not on the list") returns Not on the list.

A message is clearer for the person reading the sheet than an error value, and unlike wrapping the lookup in IFERROR, it only catches the “not found” case.

XLOOKUP with multiple criteria

XLOOKUP takes one value to find, but you can make it check two columns by searching for a 1. With products in A2:A20, sizes in B2:B20 and prices in C2:C20, =XLOOKUP(1,(A2:A20=F1)*(B2:B20=F2),C2:C20) returns the price for the product named in F1 and the size in F2.

The two comparisons each give TRUE or FALSE for every row. Multiplied together, they make a 1 where both are true and a 0 everywhere else, so XLOOKUP returns the price from the first row with a 1. For a third condition, multiply by one more bracket, such as (D2:D20=F3).

XLOOKUP vs VLOOKUP

XLOOKUP and VLOOKUP both find a value and return something from the same row. Their defaults differ, and so does what happens when the table changes or the value is missing.

FeatureXLOOKUPVLOOKUP
The answer columnYou select itYou count to it, such as 3
Match when you leave the option outExactApproximate, so you add FALSE
Where the answer can beEither side of the search columnOnly to its right
After you insert a column in the tableKeeps workingThe column number may point at the wrong column
When nothing matchesYour message, or #N/A#N/A, unless you wrap it in IFERROR
Excel versionsMicrosoft 365, Excel 2021 and laterEvery version

Common mistakes

  • =XLOOKUP(B9,A2:A7,C2:C8) shows #VALUE! because the two ranges have different numbers of cells. The search range and the answer range must be the same size.
  • Filled down a column, A2:A7 becomes A3:A8, then A4:A9. Lock the ranges with dollar signs, $A$2:$A$7, before you fill the formula down.
  • “Portugal ” with a trailing space, or a code stored as text when the table holds numbers, gives #N/A even though the match looks right. Check the cell that holds the lookup value first.
  • XLOOKUP isn’t in Excel 2019 or earlier, where the formula shows #NAME?. For workbooks shared with people on those versions, use VLOOKUP or INDEX with MATCH.

Frequently asked questions

Is XLOOKUP better than VLOOKUP?

For most lookups, yes. It finds an exact match by default, can return a column to the left of the one it searches, keeps working when columns are inserted, and has a built-in message for “not found”. VLOOKUP is still worth knowing because older workbooks are full of it.

Why is XLOOKUP not finding a value that exists?

The two values only look the same: a trailing space, or a number stored as text on one side, is enough to give #N/A. Test them in a spare cell with a formula such as =B9=A5, where FALSE means they differ. TRIM removes stray spaces, and VALUE turns numbers stored as text back into numbers.

How do I use XLOOKUP between two sheets?

Point the search range and the answer range at the other sheet, as in =XLOOKUP(A2,Prices!A2:A50,Prices!C2:C50). You don’t have to type the sheet name: click the other sheet’s tab while you write the formula and Excel adds it. A name with spaces goes in single quotes, such as 'Price list'!A2:A50.

Which versions of Excel have XLOOKUP?

Microsoft 365, Excel for the web, and Excel 2021 or later. Excel 2019 and earlier don’t have it.

Can XLOOKUP return more than one column?

Yes. Give it a return range several columns wide, such as B2:C7, and the results spill into the cells to the right of the formula.

How do I find the last match instead of the first?

Set search_mode to -1: =XLOOKUP(B9,A2:A20,C2:C20,"Not found",0,-1) searches from the bottom up, which finds the most recent entry in a list sorted by date.