Skip to content

Lesson 19 of 92 · Free Excel Course

Excel

Excel XLOOKUP: The Easier Way to Look Up Anything (Plus INDEX MATCH)

Learn XLOOKUP in Excel step by step: exact matches, left lookups, price bands, last match, several columns, and INDEX MATCH for older versions.

In the last lesson you used VLOOKUP to pull a price out of a list. It works, but it has quirks: it can only look to the right, it needs a column number that breaks when someone inserts a column, and it does an approximate match unless you remember to type FALSE. XLOOKUP fixes all of that. You tell it what to find, where to look and what to bring back, and that's it. This lesson walks through XLOOKUP from the first formula to price bands and "find the last one", then shows INDEX and MATCH, the classic combination that does the same job in older versions of Excel.

What XLOOKUP does and why it replaces VLOOKUP

XLOOKUP searches one column (or row) for a value and returns the matching item from another column. The full shape is:

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

Only the first three parts are required:

  • lookup_value: what you're looking for, such as a product ID in a cell.
  • lookup_array: the column to search, such as A2:A9.
  • return_array: the column holding the answer, such as D2:D9.

The three in square brackets are optional extras you'll meet below: a message for when nothing is found, the type of match, and the direction of the search.

Compared with VLOOKUP, four things get easier:

VLOOKUPXLOOKUP
Approximate match unless you add FALSEExact match by default
Can only return columns to the rightReturns from either side
Needs a column number like 3Points straight at the answer column
One column per formulaCan return several columns at once

The column-number point matters more than it looks. If you insert a column inside a VLOOKUP table, its "3" now points at the wrong column and your answers quietly change. XLOOKUP refers to the actual range, so Excel adjusts it for you.

Your first XLOOKUP, step by step

Here is a small product list. You want the price of product P-105.

  1. Type P-105 in G2. This is the value to look up.
  2. Click H2 and type =XLOOKUP(.
  3. Click G2, then type a comma.
  4. Drag over A2:A9 (the IDs), then type a comma.
  5. Drag over D2:D9 (the prices).
  6. Type ) and press Enter (Return on a Mac).
H2=XLOOKUP(G2,A2:A9,D2:D9)
ABCDEFGH
1IDProductCategoryPriceStockLook upResult
2P-101Desk lampOffice$24.9918P-105$45.00
3P-102NotebookOffice$3.50240
4P-103Water bottleKitchen$12.0065
5P-104Coffee mugKitchen$8.750
6P-105BackpackBags$45.0022
7P-106Phone standOffice$15.2540
8P-107Lunch boxKitchen$18.5031
9P-108Tote bagBags$22.0012
XLOOKUP finds P-105 in row 6 of the ID column and returns the price from the same row: $45.00.

Change G2 to P-102 and H2 instantly shows $3.50. The formula is the same in Excel for Microsoft 365 on Windows and Mac and in Excel for the web. If you plan to copy the formula down a column, lock the ranges with dollar signs, like $A$2:$A$9, as covered in Absolute and relative references.

Show a friendly message instead of #N/A

If the ID isn't in the list, XLOOKUP returns #N/A. That's correct, but it looks like something broke. The fourth argument, if_not_found, lets you choose what to show instead:

=XLOOKUP(G3,A2:A9,D2:D9,"Not found")

With P-110 in G3, the cell now says Not found. You can also use a number, such as 0, or an empty pair of quotes "" to show nothing at all. With VLOOKUP you'd have to wrap the whole formula in IFNA or IFERROR to do the same thing.

Look to the left

VLOOKUP can't return a column to the left of the one it searches. XLOOKUP doesn't care which side the answer is on. To find the ID of the Backpack:

  1. Type Backpack in G4.
  2. In H4, type =XLOOKUP(G4,B2:B9,A2:A9).
  3. Press Enter. The answer is P-105.

The search column is B (names) and the answer column is A (IDs), which sits to its left. No rearranging of your data needed.

Return several columns at once

Make the return_array wider than one column and XLOOKUP brings back the whole row. With P-103 in G6:

=XLOOKUP(G6,A2:A9,B2:E9)

H6=XLOOKUP(G6,A2:A9,B2:E9)
GHIJK
5Look upProductCategoryPriceStock
6P-103Water bottleKitchen$12.0065
One formula in H6. The answer spills across H6:K6: name, category, price and stock for P-103.

You only type the formula in H6. The other three cells fill themselves; this is called spilling, and the shaded block is the spill range. Click I6 and the formula bar shows the formula greyed out, because it lives in H6. If any of those cells already has something in it, H6 shows #SPILL! until you clear the way.

Bands and tiers: match_mode -1 and 1

Some lookups aren't about an exact value but about which band a number falls into. Shipping costs are a classic case:

E2=XLOOKUP(D2,$A$2:$A$4,$B$2:$B$4,,-1)
ABCDE
1Order total fromShippingOrder totalShipping
2$0.00$5.99$37.40$3.99
3$25.00$3.99$50.00$0.00
4$50.00$0.00$12.99$5.99
PracticeShippingOrdersRates
With match_mode -1, an order of $37.40 has no exact match, so XLOOKUP takes the next smaller band ($25.00) and returns $3.99.

Match mode -1 means "exact match, or the next smaller value". $37.40 isn't in column A, so XLOOKUP falls back to $25.00, the biggest band that's still below it. An order of exactly $50.00 matches the free-shipping row, and $12.99 drops to the $0 band. The two commas in a row skip the if_not_found argument; Excel accepts that.

Match mode 1 works the other way: "exact match, or the next larger value". That suits box sizes. If a Small box holds up to 5 items, Medium up to 10 and Large up to 20, then an order of 7 items needs the next size up:

=XLOOKUP(7,G2:G4,H2:H4,"Split order",1) returns Medium.

An order of 25 items has nothing larger to fall back on, so this time the if_not_found text appears: Split order. Keep band tables sorted from smallest to largest. XLOOKUP doesn't strictly need it for -1 and 1, but it makes the table much easier to check by eye.

Wildcards: match_mode 2

Match mode 2 turns on wildcards. An asterisk * stands for any run of characters and a question mark ? for exactly one character. To find the price of whatever product ends in "mug":

=XLOOKUP("*mug",B2:B9,D2:D9,"Not found",2) returns $8.75, the Coffee mug.

Without the 2 at the end, XLOOKUP would hunt for the literal text "*mug" and come back with Not found. If you ever need to search for a real asterisk or question mark, put a tilde in front of it: ~*.

Find the last match: search_mode -1

When a value appears more than once, XLOOKUP returns the first one it meets, searching from the top. In an orders log sorted by date, that's the oldest order. Set the sixth argument, search_mode, to -1 and it searches from the bottom up instead:

G2=XLOOKUP(E2,B2:B7,A2:A7,"None",0,-1)
ABCDEFG
1DateProductQtyProductFirst orderLatest order
211/2/2026Desk lamp2Desk lamp11/2/202611/18/2026
311/5/2026Notebook10
411/9/2026Desk lamp1
511/14/2026Backpack3
611/18/2026Desk lamp4
711/20/2026Notebook6
PracticeShippingOrdersRates
F2 uses a plain XLOOKUP and finds the first Desk lamp order. G2 adds search_mode -1 and finds the latest: 11/18/2026.

The 0 before the -1 keeps the exact match. If the answer shows as a number like 46344, format the cell as a date (see Dates and times).

Which versions of Excel have XLOOKUP?

According to Microsoft, XLOOKUP is in Excel for Microsoft 365 (Windows and Mac), Excel 2021, Excel 2024, Excel for the web and the Excel apps for iPhone, iPad and Android. It is not in Excel 2019 or Excel 2016.

That matters when you share files. If someone opens your workbook in Excel 2019, your XLOOKUP formulas won't calculate there, and they'll typically see #NAME?, Excel's way of saying it doesn't recognise a name. If you can't be sure what everyone uses, either point them to the free Excel for the web or use INDEX and MATCH.

INDEX and MATCH for older versions

Before XLOOKUP, the standard flexible lookup was two functions working together.

  • MATCH finds a position. =MATCH("P-105",A2:A9,0) returns 5, because P-105 is the fifth item in A2:A9. The 0 at the end means exact match. Leave it out and MATCH assumes the list is sorted and looks for the nearest smaller value, which gives wrong answers on an ordinary list.
  • INDEX returns whatever sits at a position. =INDEX(D2:D9,5) returns the fifth price, $45.00.

Put MATCH inside INDEX and you have a lookup:

=INDEX(D2:D9,MATCH(G7,A2:A9,0))

Read it inside out: MATCH finds which row P-105 is in, then INDEX fetches the price from that row. To build it:

  1. Click the answer cell and type =INDEX(.
  2. Drag over the answer column, D2:D9, then type a comma.
  3. Type MATCH(, click the lookup cell G7, type a comma, drag over A2:A9, then type ,0).
  4. Type ) to close INDEX and press Enter.

Like XLOOKUP, INDEX and MATCH can look left (=INDEX(A2:A9,MATCH("Backpack",B2:B9,0)) gives P-105), and inserting a column doesn't break it. It works in every version of Excel, including 2016 and 2019.

Two-way lookups: find a row and a column

Sometimes the answer sits where a row and a column meet, like a shipping rate grid with box sizes down the side and zones across the top. Give INDEX the whole grid plus two MATCHes, one for the row and one for the column:

H2=INDEX(B2:D4,MATCH(F2,A2:A4,0),MATCH(G2,B1:D1,0))
ABCDEFGH
1BoxZone 1Zone 2Zone 3BoxZoneRate
2Small$4.50$5.25$6.10MediumZone 3$9.20
3Medium$6.75$7.80$9.20
4Large$9.40$11.15$13.60
PracticeShippingOrdersRates
MATCH finds Medium in row 2 of the sizes and Zone 3 in column 3 of the zones. INDEX returns the value where they cross: $9.20.

The XLOOKUP version nests one lookup inside another: =XLOOKUP(F2,A2:A4,XLOOKUP(G2,B1:D1,B2:D4)). The inner XLOOKUP returns the whole Zone 3 column; the outer one picks the Medium row from it. Same answer, $9.20.

XMATCH, briefly: it's the modern MATCH, available in the same versions as XLOOKUP. =XMATCH("Backpack",B2:B9) returns 5, exact match by default, and it has the same match_mode and search_mode options. You can swap it into INDEX in place of MATCH.

Try it yourself

Download the practice workbook. Yellow cells are where you type.

  1. On the Practice sheet, in H2 type =XLOOKUP(G2,A2:A9,D2:D9). You should get $45.00.
  2. In H3, look up P-110 with "Not found" as the fourth argument. It should say Not found.
  3. In H4, find the ID of the Backpack by searching column B and returning column A: P-105.
  4. In H5, use "*mug" with match_mode 2 to get $8.75. In H6, return B2:E9 for P-103 and watch it spill.
  5. In H7, rebuild the P-105 price with INDEX and MATCH. In H8, try XMATCH for Backpack (5).
  6. On Shipping, fill E2:E4 using match_mode -1 ($3.99, $0.00, $5.99) and K2:K4 using match_mode 1 (Medium, Large, Split order).
  7. On Orders, fill F2 and G2: first and latest Desk lamp orders (11/2/2026 and 11/18/2026).
  8. On Rates, make H2 show $9.20 with INDEX and two MATCHes.

Compare with the Answers sheet when you're done.

Common mistakes

  • Ranges of different sizes. =XLOOKUP(G2,A2:A9,D2:D8) gives #VALUE!. The lookup and return ranges must have the same number of rows.
  • Forgetting the 0 in MATCH. Without it, MATCH assumes sorted data and can return the wrong row with no error at all.
  • Wildcards without match_mode 2. XLOOKUP treats * as plain text unless you set the fifth argument to 2.
  • Blocking a spill. Something typed to the right of a multi-column XLOOKUP causes #SPILL!. Clear those cells.
  • Hidden differences in the lookup value. "P-105 " with a trailing space isn't "P-105", and the number 105 isn't the text "105". Both give #N/A.
  • Mixing up -1. In XLOOKUP, -1 means next smaller. In MATCH, -1 means next larger and needs data sorted largest first. Don't copy the number between them.
  • Sharing with Excel 2019 users. They'll see #NAME?. Use INDEX and MATCH for those files.

What's next

You can now look up almost anything, in any direction. Next, Sort and filter shows how to put your lists in order and show only the rows you need, including the FILTER function, a lookup that returns every match. Or go back to the full Excel course. For catching #N/A around INDEX and MATCH, see the IFNA function page.

Frequently asked questions

Is XLOOKUP better than VLOOKUP?

For most jobs, yes. XLOOKUP looks for an exact match unless you tell it otherwise, can return a column to the left of the one you search, has no column number to break when you insert a column, and lets you choose your own message instead of #N/A. VLOOKUP still works and is worth knowing for older files: see VLOOKUP and HLOOKUP.

Why don't I have XLOOKUP in my Excel?

Microsoft says XLOOKUP is not available in Excel 2016 or Excel 2019. It is in Microsoft 365 (Windows and Mac), Excel 2021, Excel 2024, Excel for the web and the phone and tablet apps. In an older version, a formula that uses it typically shows #NAME?. Use INDEX and MATCH instead, or open the file free in Excel for the web.

XLOOKUP vs INDEX MATCH: which should I use?

Use XLOOKUP if everyone who opens the file has Excel 2021 or newer: it's one function and easier to read. Use INDEX and MATCH when the workbook must also work in Excel 2019 or 2016. Both can look left and both survive inserted columns.

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

Set the sixth argument, search_mode, to -1. For example =XLOOKUP(E2,B2:B7,A2:A7,"None",0,-1) searches from the bottom of the list up, so it returns the most recent entry in a log that's in date order.

Can XLOOKUP return more than one column?

Yes. Make the return_array several columns wide, such as B2:E9. The answer spills across that many cells to the right. Keep those cells empty, or you'll get #SPILL!.

Why is my XLOOKUP returning #N/A when the value is there?

Usually the two values aren't really the same: an extra space at the end, or a number stored as text in one place and a real number in the other. TRIM helps with spaces (see Text functions). Also check that you didn't set match_mode to something other than 0 by accident.