On this page ⌄
- The XLOOKUP syntax
- A basic XLOOKUP example
- Look up a value to the left
- Return several columns at once
- When the value isn't there
- Approximate matches with match_mode
- Search from the bottom with search_mode
- Nesting XLOOKUPs
- XLOOKUP vs VLOOKUP
- Common XLOOKUP errors and how to fix them
- Which versions of Excel have XLOOKUP?
- Key takeaways
XLOOKUP is the lookup function most people should learn first. You tell it what to find, where to look and what to bring back, and it does the rest. It's simpler than VLOOKUP, it can look in any direction, and it uses an exact match unless you ask for something else.
All the examples below use this small staff list, in cells A1:D9:
| A: ID | B: Name | C: Department | D: Salary | |
|---|---|---|---|---|
| 2 | E101 | Hannah Lee | Sales | $52,000 |
| 3 | E102 | Omar Haddad | Finance | $61,000 |
| 4 | E103 | Grace Kim | Marketing | $48,500 |
| 5 | E104 | Diego Ruiz | Sales | $57,500 |
| 6 | E105 | Priya Shah | IT | $72,000 |
| 7 | E106 | Tom Becker | Finance | $66,000 |
| 8 | E107 | Lena Fischer | IT | $69,500 |
| 9 | E108 | Sam Okafor | Marketing | $51,000 |
The XLOOKUP syntax
XLOOKUP has three required arguments and three optional ones. Most of the time you only need the first three.
| Argument | What it means | Example |
|---|---|---|
| lookup_value | The value you're looking for | "Grace Kim" |
| lookup_array | The column (or row) to search in | B2:B9 |
| return_array | The column (or row) to bring a value back from | C2:C9 |
| if_not_found | Optional. What to show if there's no match | "Not found" |
| match_mode | Optional. 0 = exact match (the default), -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcards | 0 |
| search_mode | Optional. 1 = search from the top (the default), -1 = search from the bottom | -1 |
The one rule to remember: lookup_array and return_array must be the same size. If you search B2:B9, return from C2:C9, not C2:C10.
A basic XLOOKUP example
Say you want to know which department Grace Kim works in. Search the names in column B, and return the matching value from column C:
=XLOOKUP("Grace Kim", B2:B9, C2:C9)→ MarketingRead it out loud and it makes sense: find "Grace Kim" in B2:B9, and give me the value from C2:C9 in the same row. Excel finds the name in the third row of the range, so it returns the third value of C2:C9.
In a real workbook you'd usually point at a cell instead of typing the name, so the result updates when the name changes. If the name is in G2:
=XLOOKUP(G2, B2:B9, C2:C9)Now try one yourself. The sheet below is live: click cells to add them to your formula, then press Enter.
Try it yourself
A live spreadsheet. Type a formula and press Enter to check it.
What is Priya Shah's salary?
Write your formula in the green cell, J2.
Click a cell to add it to your formula, drag to select a range, or click a column letter for the whole column.
Look up a value to the left
VLOOKUP can only return columns to the right of the column it searches. XLOOKUP doesn't care about direction, because the lookup and return ranges are separate. To find the ID of a person by name, search column B and return column A:
=XLOOKUP("Tom Becker", B2:B9, A2:A9)→ E106Return several columns at once
If return_array is more than one column wide, XLOOKUP returns the whole row of results and spills it into the cells to the right:
=XLOOKUP("E104", A2:A9, B2:D9)→ Diego Ruiz | Sales | $57,500This is handy for building a small lookup panel: type an ID in one cell and see the name, department and salary next to it. The cells the result spills into must be empty, or you'll see a #SPILL! error.
When the value isn't there
If XLOOKUP can't find a match, it returns #N/A. That's correct, but it looks like something broke. Use the fourth argument to show a friendlier message:
=XLOOKUP("Ana Lopez", B2:B9, D2:D9)→ #N/A=XLOOKUP("Ana Lopez", B2:B9, D2:D9, "No such employee")→ No such employeeThis is better than wrapping the whole formula in IFERROR, because IFERROR also hides real mistakes, like a typo in a range.
Approximate matches with match_mode
Some lookups don't have an exact answer. Commission tiers, tax brackets and grade boundaries all work by finding the band a number falls into. Say this tier table is in A2:B5 on another sheet:
| A: Sales from | B: Commission | |
|---|---|---|
| 2 | $0 | 2% |
| 3 | $10,000 | 4% |
| 4 | $25,000 | 6% |
| 5 | $50,000 | 8% |
To find the rate for $31,500 in sales, ask for an exact match or the next smaller value with match_mode -1:
=XLOOKUP(31500, A2:A5, B2:B5, , -1)→ 6%The empty space between the two commas skips the if_not_found argument. Unlike VLOOKUP's approximate match, XLOOKUP doesn't need the table to be sorted for this to work.
match_mode 2 turns on wildcards, where * means "any characters". This finds the first name starting with "Sam":
=XLOOKUP("Sam*", B2:B9, C2:C9, , 2)→ MarketingSearch from the bottom with search_mode
By default XLOOKUP returns the first match from the top. If a value appears more than once and you want the last one, set search_mode to -1. Finance appears twice in the list:
=XLOOKUP("Finance", C2:C9, B2:B9)→ Omar Haddad=XLOOKUP("Finance", C2:C9, B2:B9, , 0, -1)→ Tom BeckerThis is useful for things like "the most recent order for this customer" in a list sorted by date.
Nesting XLOOKUPs
Because XLOOKUP returns a value, you can feed that value into another XLOOKUP. For example, the inner XLOOKUP can find a person's department, and the outer one can look that department up in a second table to find its bonus rate. You can practice exactly that in the exercises at the end of this guide.
XLOOKUP vs VLOOKUP
If everyone who opens your file has Excel 365 or Excel 2021 or later, use XLOOKUP. Here's why:
- Exact match by default. VLOOKUP defaults to an approximate match, which quietly returns wrong answers if you forget
FALSE. - It looks left. VLOOKUP can only return columns to the right of the search column.
- Inserting columns doesn't break it. VLOOKUP uses a column number like 3, which points at the wrong column after you insert one.
- Built-in "not found" message and search from the bottom, with no extra functions.
VLOOKUP still matters, though. Older files are full of it, and many Excel job tests ask for it. Our VLOOKUP guide covers it step by step.
Common XLOOKUP errors and how to fix them
| Error | Usual cause | Fix |
|---|---|---|
#N/A | No match. Often an extra space or a number stored as text | Check the spelling, use TRIM on the data, or add if_not_found |
#VALUE! | lookup_array and return_array are different sizes | Make both ranges cover the same rows |
#SPILL! | The result needs more cells, but they aren't empty | Clear the cells to the right or below |
#NAME? | Your version of Excel doesn't have XLOOKUP | Use INDEX and MATCH, or VLOOKUP |
Which versions of Excel have XLOOKUP?
XLOOKUP works in Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. It isn't available in Excel 2019 or older. Google Sheets supports XLOOKUP too, with the same arguments.
Key takeaways
- XLOOKUP needs three things: what to find, where to look and what to return.
- The lookup and return ranges must be the same size.
- Use the fourth argument for a friendly "not found" message.
- Use match_mode -1 or 1 for bands and tiers, and search_mode -1 to get the last match.
Practice
Keep going with XLOOKUP exercises
Reading gets you started. Solving a few of these is what makes it stick.
- 1Find a salaryFreeWhat is Priya Shah's salary?→
- 2Chain two lookups PremiumWhat bonus % does Diego Ruiz get? Find his department, then look it up in the bonus table in G1:H5.→
- 3When it's not there PremiumLook up the name of employee E110. That ID doesn't exist, so return "Not found" instead of an error.→

About the author
Brian Millot
Brian Millot is an indie hacker based in France who builds small, focused web products. He built and runs Excel Formula Practice, from the in-browser spreadsheet that checks your formulas to the exercise library, and he writes the formula guides.