XMATCH Function in Excel: Match Modes, Reverse Search, and INDEX Lookups

Isometric spreadsheet illustration showing XMATCH in Excel locating a target row with bidirectional search

For decades, Excel’s classic MATCH function had an infamous trap: if you forgot to type 0 as the third argument, it defaulted to an approximate match and silently returned the wrong row on unsorted data. With XMATCH in Excel, Microsoft fixed that default and added reverse searching, wildcard matching, and high-speed binary search in one modern function.

Availability & Compatibility: Per the official XMATCH function documentation, XMATCH is available in Excel for Microsoft 365 (Windows and Mac), Excel for the web, Excel 2024, and Excel 2021 (as well as Google Sheets). Older perpetual releases such as Excel 2019 and Excel 2016 do not support XMATCH and will display a #NAME? error—if you share workbooks with those users, stick to classic MATCH.

How XMATCH in Excel Works (Syntax & Arguments)

XMATCH searches for a specified item in a range or array and returns its 1-based relative position (for example, 3 if it’s the third row or third column). Unlike XLOOKUP, which returns a cell’s value, XMATCH returns a numeric index you can feed into INDEX, CHOOSECOLS, or conditional checks:

=XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])
  • lookup_value (Required): The value, text string, or cell reference you want to find.
  • lookup_array (Required): The single row or single column range to search.
  • [match_mode] (Optional): Controls how Excel matches values: 0 for Exact match (the new default), -1 for Exact match or next smallest item, 1 for Exact match or next largest item, and 2 for Wildcard match (*, ?, ~).
  • [search_mode] (Optional): Controls search direction and speed: 1 searches first-to-last (default), -1 searches last-to-first (reverse search), 2 runs an ascending binary search, and -2 runs a descending binary search.

2D Matrix Lookups With INDEX and XMATCH

Suppose your Practice sheet tracks quarterly sales across six rep rows in A6:E11 (Q1 through Q4 in B5:E5). You want to look up the sales figure for the Rep in H6 (Elena Rostova) and Quarter in H7 (Q3). First, find the row position in H8 and column position in H9:

=XMATCH(H6, A6:A11)
=XMATCH(H7, B5:E5)

Because XMATCH defaults to exact match (0), you don’t even need a third argument. Combine both inside INDEX in cell H10 to return $38,500 cleanly:

=INDEX(B6:E11, XMATCH(H6, A6:A11), XMATCH(H7, B5:E5))

Notice how Maya Lin appears twice in our dataset (row 1 and row 5). By default, XMATCH finds the first occurrence (row 1). To locate her last entry from the bottom up, pass -1 for search_mode: =XMATCH("Maya Lin", A6:A11, 0, -1), which returns 5. If you want to return all matching rows for Maya Lin at once instead of a single position, use the FILTER function in Excel.

XMATCH vs. Classic MATCH: Key Differences

See why XMATCH in Excel replaces legacy MATCH in every modern workbook:

FeatureXMATCHClassic MATCH
Default Match ModeExact match (0)Approximate match (1)
Reverse Search (Bottom-Up)Yes (search_mode = -1)No
Unsorted Approximate MatchYes (-1 or 1 works unsorted)Requires sorted data
Wildcard ModeExplicit (match_mode = 2)Implicit when 0
CompatibilityExcel 2021+, M365, SheetsAll Excel versions

Troubleshooting #N/A, #VALUE!, and Binary Search Bugs

  • #N/A error: Returned when lookup_value isn’t found in lookup_array. Check for trailing spaces, text-formatted numbers, or misspelled names—see our full guide on how to fix the #N/A error in Excel.
  • Wrong result in binary search (search_mode 2 or -2): Per Microsoft Support, binary search relies strictly on lookup_array being sorted in ascending (2) or descending (-2) order. If the range isn’t sorted, Excel silently returns invalid positions.
  • Wildcards (* or ?) treated literally: Unlike legacy MATCH, XMATCH does not enable wildcards in exact-match mode (0). Set match_mode to 2 whenever you search with * or ?.
  • #NAME? error: The workbook was opened in Excel 2019 or earlier, where XMATCH is not supported.

Frequently Asked Questions

Download the practice workbook

The same data as this tutorial, with empty answer cells and a Solutions sheet.

Team Xl in Excel

Team Xl in Excel

Spreadsheet Architect & Educator at Xl in Excel. Sharing advanced formulas, dynamic arrays, and clean data modeling techniques.

Learn More About Team Xl in Excel →

Leave a Reply

Your email address will not be published. Required fields are marked *

Zoom: 100% | UTF-8 | Xl in Excel