ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Lookups
  3. XMATCH Function in Excel: Find a Position

XMATCH Function in Excel: Find a Position

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

XMATCH returns the position of a value in a row or column. Write =XMATCH(lookup_value, lookup_array): =XMATCH("Omar",B2:B7) returns 2 if Omar is the second item. It does an exact match by default, can match the next smaller or larger value, supports wildcards and can search from the bottom up. It needs Excel 2021 or Microsoft 365.

Key takeaways

  • XMATCH returns a position (a number), not the value itself.
  • It defaults to an exact match, so you don't need to type 0 like you do with MATCH.
  • match_mode: 0 exact, -1 exact or next smaller, 1 exact or next larger, 2 wildcard.
  • search_mode -1 searches from the bottom, which finds the last occurrence.
  • Pair XMATCH with INDEX to return a value from any column.
On this page+
  1. What does XMATCH return?
  2. How to find a position with XMATCH
  3. How to find the last match with search_mode -1
  4. Next smaller, next larger and wildcard matches
  5. How to use XMATCH with INDEX
  6. XMATCH vs MATCH: what changed
  7. Common XMATCH mistakes
  8. Practise it

The XMATCH function in Excel finds a value in a list and returns its position, such as 2 for the second item. It is the modern version of MATCH: it does an exact match by default, can search from the bottom up, and understands wildcards. This guide shows each option on one small order list, and how to combine XMATCH with INDEX to return a value.

XMATCH needs Excel 2021, Excel 2024, Microsoft 365 or Excel for the web. In older versions, use MATCH instead.

What does XMATCH return?#

XMATCH returns a position, not a value. If you ask where "Omar" is in a list of names and he is second, XMATCH returns 2. On its own, that number answers questions like "which row is this in?" or "is this value in the list at all?". Combined with INDEX, it becomes a full lookup.

The syntax has two required parts and two optional ones:

Excel formula
=XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])
PartWhat it meansDefault
lookup_valueThe value to find
lookup_arrayOne row or one column to search
match_mode0 exact, -1 exact or next smaller, 1 exact or next larger, 2 wildcard0
search_mode1 first to last, -1 last to first, 2 or -2 binary search on sorted data1

All the examples use this order list in A1:C7:

ABC
1OrderCustomerAmount
21001Lena250
31002Omar120
41003Lena310
51004Ravi95
61005Omar410
71006Lena180

How to find a position with XMATCH#

For a basic exact match, give XMATCH the value and the range:

Excel formula
=XMATCH("Omar",B2:B7)

The result is 2. Omar is in B3, which is the second cell of B2:B7. The count starts at the first cell of the range, not at row 1 of the sheet.

XMATCH returns the first match it finds, so Omar's second order in B6 is ignored. If the value isn't in the list, the result is #N/A. That makes XMATCH a quick way to check membership: =ISNUMBER(XMATCH("Ravi",B2:B7)) returns TRUE if Ravi is in the list.

XMATCH is not case-sensitive, so "omar" finds "Omar" too.

XMATCH can also look up several values at once. =XMATCH({"Ravi","Omar"},B2:B7) returns 4 and 2, spilled into two cells side by side. Point the first argument at a range of names instead, and you get one position per name.

How to find the last match with search_mode -1#

Set search_mode to -1 to search from the bottom up. This finds the last occurrence, such as a customer's most recent order:

Excel formula
=XMATCH("Lena",B2:B7,0,-1)

The result is 6. Even though XMATCH started at the bottom, the position is still counted from the top: Lena's last order is the sixth row of the range. The 0 keeps the match exact. You must type it, because search_mode is the fourth argument and match_mode sits before it.

The guide to looking up the last match shows more ways to do this, including in older Excel.

Next smaller, next larger and wildcard matches#

match_mode controls what counts as a match when the exact value isn't there.

FormulaWhat it asksResult
=XMATCH(300,C2:C7,1)Position of 300, or the next larger amount3 (310)
=XMATCH(300,C2:C7,-1)Position of 300, or the next smaller amount1 (250)
=XMATCH("R*",B2:B7,2)First name starting with R4 (Ravi)

The amounts in column C aren't sorted, and that's fine. XMATCH's next smaller and next larger modes find the closest value anywhere in the list. MATCH is stricter: its types 1 and -1 need sorted data, as explained in MATCH type 0 vs 1 vs -1.

In wildcard mode, * stands for any number of characters, ? for exactly one, and ~ lets you search for a real asterisk or question mark. Wildcards only work when match_mode is 2.

How to use XMATCH with INDEX#

XMATCH finds the row, and INDEX returns the value from that row in another column. To get the amount of Lena's last order:

Excel formula
=INDEX(C2:C7,XMATCH("Lena",B2:B7,0,-1))

XMATCH returns 6, and the sixth value of C2:C7 is 180. Both ranges must start on the same row, or INDEX will pick the wrong cell.

For a two-way lookup, use one XMATCH for the row and another for the column: =INDEX(A2:C7,XMATCH(1004,A2:A7),XMATCH("Amount",A1:C1)) returns 95. The INDEX MATCH guide explains this pattern step by step, and it extends to lookups with multiple criteria.

XMATCH vs MATCH: what changed#

XMATCH fixes the main traps in MATCH:

XMATCHMATCH
Default matchExactApproximate (type 1)
Search from the bottomYes, search_mode -1No
Next larger on unsorted dataYesNo, needs descending sort
Wildcardsmatch_mode 2Type 0
Works inExcel 2021, 2024, Microsoft 365Every version

Forgetting the 0 in MATCH is a classic mistake that gives wrong answers with no error. XMATCH avoids it. For a full side-by-side, read MATCH vs XMATCH, and for MATCH on its own see the MATCH function in Excel and the MATCH function guide.

Common XMATCH mistakes#

  1. Using a range with several columns. XMATCH searches one row or one column. B2:C7 returns #VALUE!.
  2. Skipping match_mode when setting search_mode. =XMATCH("Lena",B2:B7,-1) sets match_mode to -1, not search_mode. Write 0,-1.
  3. Expecting a value instead of a position. If you want the amount, wrap XMATCH in INDEX.
  4. Sharing the file with older Excel. Anyone on Excel 2019 or earlier sees #NAME?. Use MATCH with 0 if the file must work everywhere.

Practise it#

Positions click once you've counted them yourself on a real list. Practise XLOOKUP and XMATCH match modes in a live spreadsheet: you type the formula and it checks the result instantly. Then practise INDEX and MATCH to turn positions into full lookups.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Lena appears three times. In E2, use XMATCH to find the position of her last order in B2:B7: exact match (0) and search from the bottom (-1).

fx
ABCDEF
1
Order
Customer
Amount
Last Lena
2
1001
Lena
250
3
1002
Omar
120
4
1003
Lena
310
5
1004
Ravi
95
6
1005
Omar
410
7
1006
Lena
180
8
9
10

Tip: Four arguments: "Lena", the range B2:B7, 0 for exact, and -1 to search from the last row up.

Practise this in a lesson

LessonXLOOKUP wildcards and match modesSearch partial names with XLOOKUP's wildcard mode, and place values into tiers with next-smaller and next-larger matches.LessonINDEX and MATCHCombine INDEX and MATCH to look up in any direction, including returning a column to the left of the one you search.Function guideMATCHLearn how Excel's MATCH finds the position of a value, why the 0 matters, and how it powers INDEX/MATCH. Includes a live exercise.

Frequently asked questions

What does XMATCH do in Excel?

+

XMATCH finds a value in a row or column and returns its position as a number. For example, if Omar is the second name in a list, =XMATCH("Omar",B2:B7) returns 2.

What is the difference between MATCH and XMATCH?

+

XMATCH defaults to an exact match, can search from the bottom up, and its next smaller and next larger modes work on unsorted data. MATCH defaults to an approximate match and works in every Excel version.

Which Excel versions have XMATCH?

+

XMATCH is available in Excel 2021, Excel 2024, Microsoft 365 and Excel for the web. In older versions it shows #NAME?.

How do I find the last occurrence with XMATCH?

+

Set the fourth argument, search_mode, to -1. =XMATCH("Lena",B2:B7,0,-1) searches from the bottom and returns the position of the last Lena, still counted from the top.

Sources

  • XMATCH function - Microsoft Support
  • MATCH function - Microsoft Support
  • INDEX function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What does XMATCH return?
  2. How to find a position with XMATCH
  3. How to find the last match with search_mode -1
  4. Next smaller, next larger and wildcard matches
  5. How to use XMATCH with INDEX
  6. XMATCH vs MATCH: what changed
  7. Common XMATCH mistakes
  8. Practise it

Keep reading

Comparisons· 7 min read

MATCH vs XMATCH in Excel

Use XMATCH in Excel 2021, Excel 2024 or Microsoft 365: it defaults to an exact match, can search from the last row up, and finds the next smaller or larger value without sorted data. Use MATCH with 0 as its third argument when the file must work in older Excel. Both return a position, usually fed into INDEX.

Lookups· 6 min read

INDEX MATCH in Excel: The Beginner's Guide

INDEX MATCH is a lookup built from two functions. MATCH finds the position of a value in one column, and INDEX returns the item at that position from another column: =INDEX(A2:A9,MATCH(G2,B2:B9,0)). It can look left, it keeps working when columns are inserted, and it runs in every version of Excel.

Lookups· 6 min read

Lookup With Multiple Criteria in Excel

To look up a value that must match two or more criteria, multiply the tests and look up 1: =XLOOKUP(1,(A2:A8=F2)*(B2:B8=F3),C2:C8). Each test gives 1 for TRUE and 0 for FALSE, so only rows that pass every test become 1. In Excel 2019 and earlier, use =INDEX(C2:C8,MATCH(1,(A2:A8=F2)*(B2:B8=F3),0)) or a helper column.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free