toolrota

Excel XMATCH function guide: differences from MATCH, with practical examples

XMATCH is the newer, more flexible version of MATCH. We explain exact match, wildcards, reverse search and binary search with examples.

Serkan Akyürek··3 min read
Excel XMATCH function guide: differences from MATCH, with practical examples – Excel

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])

ArgumentMeaning
lookup_valueThe value whose position you want
lookup_arrayA single column or row to search
match_mode0 exact, -1 exact or next smaller, 1 exact or next larger, 2 wildcard
search_mode1 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.
Two-way lookup with XMATCH
  1. 1

    Find the row heading with XMATCH

  2. 2

    Find the column heading with XMATCH

  3. 3

    Place both numbers inside INDEX

  4. 4

    Check the result with one or two examples

  5. 5

    Copy the formula across the table

Which one when?

SituationSuggestion
File shared with older versionsMATCH
Finding the last matching recordXMATCH, search mode -1
New file, exact matchXMATCH
Returning the value directlyXLOOKUP

To fetch values from a table, see our XLOOKUP guide and our INDEX MATCH guide.

Common mistakes

  1. Giving the lookup array several columns. It must be a single column or row.
  2. Using an asterisk without turning on wildcard mode.
  3. Using binary search on unsorted data. Results become unreliable.
  4. 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.

Share
Published:
Author
Serkan Akyürek

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.