
XMATCH is a modern Excel function that finds the position of a value in a list. It was designed to replace the older MATCH: it looks for an exact match by default, supports searching from the bottom up and works with wildcards. It is useful alone, but its real strength shows with INDEX and XLOOKUP. It is available in Microsoft 365 and Excel 2021 and later.
Syntax
XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])
| Argument | Meaning |
|---|---|
| lookup_value | The value whose position you want |
| lookup_array | A single column or row to search |
| match_mode | 0 exact, -1 exact or next smaller, 1 exact or next larger, 2 wildcard |
| search_mode | 1 first to last, -1 last to first, 2 and -2 binary search |
Differences from MATCH
- Exact match by default: in MATCH, forgetting the last argument gives an approximate match and wrong results. XMATCH avoids that trap.
- Reverse search: you can find the last place a value appears.
- Wildcards: mode 2 lets you use asterisk and question mark.
- Sturdier structure: formulas break less when the range is extended.
Examples
- Finding a row: find which row a product code is in.
- Latest record: set the search mode to -1 to find a customer's most recent order.
- Wildcards: find the first record starting with "Ahmet*".
- Two-way lookup: find the row and column numbers with two separate XMATCH calls inside INDEX.
- 1
Find the row heading with XMATCH
- 2
Find the column heading with XMATCH
- 3
Place both numbers inside INDEX
- 4
Check the result with one or two examples
- 5
Copy the formula across the table
Which one when?
| Situation | Suggestion |
|---|---|
| File shared with older versions | MATCH |
| Finding the last matching record | XMATCH, search mode -1 |
| New file, exact match | XMATCH |
| Returning the value directly | XLOOKUP |
To fetch values from a table, see our XLOOKUP guide and our INDEX MATCH guide.
Common mistakes
- Giving the lookup array several columns. It must be a single column or row.
- Using an asterisk without turning on wildcard mode.
- Using binary search on unsorted data. Results become unreliable.
- Ignoring error results. If nothing is found you get #N/A; handle it with IFNA.
Frequently asked questions
Does XMATCH work in older versions? No, it isn't available in Excel 2019 and earlier.
Does it return the value or the position? The position; to get the value you need INDEX or XLOOKUP.
Summary
XMATCH makes finding positions safer and more flexible. Prefer it over MATCH in new files, and be careful when sharing with older versions.
Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.