⇄Lookups5 min read ·

How to Use XLOOKUP in Excel

Learn how XLOOKUP works with simple examples. Find a value, look to the left, return several columns, handle missing values and search from the bottom.

Quick answer

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

XLOOKUP searches for a value in one range and returns the item in the same position from another range. It replaces VLOOKUP and HLOOKUP in Excel 365 and Excel 2021 or later.

Arguments in [brackets] are optional.

On this page ⌄
  1. The XLOOKUP syntax
  2. A basic XLOOKUP example
  3. Look up a value to the left
  4. Return several columns at once
  5. When the value isn't there
  6. Approximate matches with match_mode
  7. Search from the bottom with search_mode
  8. Nesting XLOOKUPs
  9. XLOOKUP vs VLOOKUP
  10. Common XLOOKUP errors and how to fix them
  11. Which versions of Excel have XLOOKUP?
  12. 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: IDB: NameC: DepartmentD: Salary
2E101Hannah LeeSales$52,000
3E102Omar HaddadFinance$61,000
4E103Grace KimMarketing$48,500
5E104Diego RuizSales$57,500
6E105Priya ShahIT$72,000
7E106Tom BeckerFinance$66,000
8E107Lena FischerIT$69,500
9E108Sam OkaforMarketing$51,000

The XLOOKUP syntax

XLOOKUP has three required arguments and three optional ones. Most of the time you only need the first three.

ArgumentWhat it meansExample
lookup_valueThe value you're looking for"Grace Kim"
lookup_arrayThe column (or row) to search inB2:B9
return_arrayThe column (or row) to bring a value back fromC2:C9
if_not_foundOptional. What to show if there's no match"Not found"
match_modeOptional. 0 = exact match (the default), -1 = exact or next smaller, 1 = exact or next larger, 2 = wildcards0
search_modeOptional. 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)→ Marketing

Read 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.

staff-list.xlsx
fx
1IDNameDepartmentSalaryStart dateDepartmentBonus
2E101Hannah LeeSales$52,000.00Mar 15, 2021Sales10%Salary
3E102Omar HaddadFinance$61,000.00Jul 1, 2019Finance6%
4E103Grace KimMarketing$48,500.00Jan 9, 2023Marketing8%
5E104Diego RuizSales$57,500.00Nov 23, 2020IT7%
6E105Priya ShahIT$72,000.00May 14, 2018
7E106Tom BeckerFinance$66,000.00Sep 5, 2022
8E107Lena FischerIT$69,500.00Feb 19, 2024
9E108Sam OkaforMarketing$51,000.00Aug 30, 2021
10
11

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)→ E106

Return 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,500

This 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 employee

This 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 fromB: Commission
2$02%
3$10,0004%
4$25,0006%
5$50,0008%

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)→ Marketing

Search 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 Becker

This 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

ErrorUsual causeFix
#N/ANo match. Often an extra space or a number stored as textCheck the spelling, use TRIM on the data, or add if_not_found
#VALUE!lookup_array and return_array are different sizesMake both ranges cover the same rows
#SPILL!The result needs more cells, but they aren't emptyClear the cells to the right or below
#NAME?Your version of Excel doesn't have XLOOKUPUse 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.

  1. 1Find a salaryFreeWhat is Priya Shah's salary?→
  2. 2Chain two lookups PremiumWhat bonus % does Diego Ruiz get? Find his department, then look it up in the bonus table in G1:H5.→
  3. 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.→
All lookups exercises →
Brian Millot

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.

Related guides

Practice makes formulas

Stop reading. Start typing formulas.

Every exercise is a real spreadsheet with instant feedback. The first two in every topic are free, no sign-up needed.