Look up in any direction with XLOOKUP

Lookups · About 5 minutes

Look up in any direction with XLOOKUP

XLOOKUP is the newer way to look things up. It works in Excel 2021, Microsoft 365 and Google Sheets, but not in Excel 2019 or older.

Instead of a table and a column number, you give it two columns: where to look, and what to bring back. The answer can sit to the left of the search column, which VLOOKUP can't do. It matches exactly by default, so there's no FALSE to forget.

=XLOOKUP(B9,C2:C7,A2:A7) reads as "find B9 in C2:C7, and bring back the value from the same row of A2:A7".

VLOOKUP and XLOOKUP: which way they lookTwo copies of one row: Kochi, Kerala, 682001. VLOOKUP finds Kochi in the first column, A, and brings back the PIN code from column C, to its right; it can only bring back from the right. XLOOKUP finds 682001 in column C and brings back Kochi from column A, to its left; it can look in any column and bring back from either side.VLOOKUPFinds in the first column, brings back from the rightABC15CityStatePIN codeKochiKerala682001XLOOKUPFinds in any column, brings back from either sideABC15CityStatePIN codeKochiKerala682001
VLOOKUP and XLOOKUP: which way they look

Part of Plus

Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.

What XLOOKUP does

XLOOKUP finds a value in one column and brings back the value from the same row of another column. You point at two ranges: where to search, and what to bring back.

It fixes the things that trip people up with VLOOKUP. It can bring back a column to the left, it matches exactly unless you ask otherwise, and it can show your own message when nothing is found.

How to write XLOOKUP

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

lookup_value
What you are looking for, like a badge number in a cell.
lookup_array
The single column (or row) to search in.
return_array
The column to bring the answer back from. It must be the same height as the search column.
if_not_found
Optional. What to show when there's no match, like "No match". Leave it out and you get #N/A.
match_mode and search_mode
Optional and rarely needed. match_mode 0 (the default) means exact, -1 means exact or next smaller, 1 means exact or next larger; search_mode -1 searches from the bottom up.

XLOOKUP worked example

A desk list shows each person's badge number to the right of their name. In B9, find the name for the badge in B8.

A desk list shows each person's badge number to the right of their name. In B9, find the name for the badge in B8.
AB
1NameBadge
2Asha104
3Ben117
4Chen121
5Dara130
6Eli142
7Femi156
8Badge130
9NameDara
B9=XLOOKUP(B8,B2:B7,A2:A7,"No match")Find 130 in B2:B7, bring back the name on the same row of A2:A7, and show "No match" if it isn't there. It shows Dara.

Common XLOOKUP mistakes

#NAME? instead of an answer

The file is open in Excel 2019 or older, which doesn't have XLOOKUP. Use INDEX and MATCH there, or open it in Microsoft 365, Excel 2021 or later, or Google Sheets.

An error as soon as you press Enter

Make the search range and the return range the same height, like B2:B7 and A2:A7. If one stops a row early, the rows can't line up.

#N/A for a code that is there

Look for a stray space or a number stored as text in the search column. Clean it with TRIM or VALUE, or add an if_not_found message for codes that really are missing.

XLOOKUP or VLOOKUP?

Pick XLOOKUP when you can. VLOOKUP only looks right, so the answer must sit to the right of the search column; XLOOKUP can bring back any column, left or right. VLOOKUP needs FALSE for an exact match and guesses without it; XLOOKUP is exact by default. VLOOKUP needs a column number, which points at the wrong column if someone inserts a column; XLOOKUP points at the return range itself, which moves with the sheet. And XLOOKUP has a built-in not-found message, where VLOOKUP needs IFNA around it.

Pick VLOOKUP when the file must open in Excel 2019 or older, where XLOOKUP shows #NAME?. XLOOKUP works in Microsoft 365, Excel 2021 and later, and Google Sheets. For an older file that also needs to look left, use INDEX and MATCH.

Questions people ask

Is XLOOKUP better than VLOOKUP?

For new work, usually: it looks left as well as right, matches exactly by default and has a built-in not-found message. VLOOKUP still matters for older files.

Why does XLOOKUP show #NAME?

Your Excel doesn't have it. XLOOKUP is in Microsoft 365, Excel 2021 and later, and Google Sheets, but not Excel 2019 or older.

Does XLOOKUP work in Google Sheets?

Yes, with the same parts in the same order.

How do I return a message if XLOOKUP finds nothing?

Add a fourth part: =XLOOKUP(E2,A2:A50,C2:C50,"Not found").

Can XLOOKUP use more than one criterion?

Yes. One way joins the columns with &: =XLOOKUP(E2&F2,A2:A50&B2:B50,C2:C50). This lesson sticks to one value.