XMATCH Function
Modern lookup that returns a position (MATCH replacement).
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| lookup_value | The value to find within lookup_array. | Required |
| lookup_array | The range or array to search (a single row or column). | Required |
| match_mode | 0 exact match (default), -1 exact or next smaller, 1 exact or next larger, 2 wildcard match. | Optional |
| search_mode | 1 search from first (default), -1 search from last, 2 binary search ascending, -2 binary search descending. | Optional |
Basic Example
Find the position of "Apple" in a list
=XMATCH("Apple", A2:A10)"Apple" is the third item in A2:A10, so XMATCH returns 3. The default is exact match.
Advanced Examples
Example 1: Wildcard match
Find the first item beginning with "App".Use match_mode 2
=XMATCH("App*", A2:A10, 2)Example 2: Approximate match (next smaller)
Find where 85 fits in an ascending sorted list.Use match_mode 1 for exact-or-next-larger, or -1 for next smaller
=XMATCH(85, B2:B10, 1)How XMATCH Works
XMATCH returns the relative position of lookup_value within lookup_array. match_mode controls matching: 0 (exact, default), -1 (exact or next smaller), 1 (exact or next larger), 2 (wildcard). search_mode controls direction: 1 (first, default), -1 (last), 2/-2 (binary search for sorted data). It is the modern replacement for MATCH and accepts arrays directly.
Important Notes & Limitations
Microsoft 365 / Excel 2021+ only (also in newer Google Sheets).
Approximate modes (-1/1) require the array to be sorted correctly.
Wildcard mode requires match_mode 2.
Common Errors & Fixes
#N/AExact match (mode 0) found nothing, or spelling mismatch.Fix: Use mode -1/1 for approximate matches, or verify the lookup value.
#VALUE! (bad search_mode)An invalid search_mode number was used.Fix: Use 1, -1, 2, or -2.
Download Practice File
XMATCH
xmatchPractice XMATCH with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the XMATCH function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps