XMATCH Function in Microsoft Excel: Syntax, Examples & Compatibility
Learn how to find the relative position of a matching item, including from the end of a list in Microsoft Excel. Includes syntax, two verified-by-reasoning results, troubleshooting and portability notes.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: find the relative position of a matching item, including from the end of a list in Microsoft Excel. The reproducible examples below use explicit values so the formula’s meaning is testable without a large workbook.
Evidence: The function name and syntax are documented in the linked vendor function reference. Expected outputs were independently reasoned or checked outside the application. These are not native Microsoft Excel test results. A guide being published here does not certify every software release or file-import scenario.
Availability and version history
- Introduced: Documented by Excel 2021; the original Microsoft 365 rollout date is not established. Version marker.
- Availability: Official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac.
- Checked: October 14, 2026; official XMATCH reference. Documentation check, not a new native test; existing example-verification notes retain their scope.
Syntax and arguments
=XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])
Exact match (0) is the default. Search mode -1 searches from last to first; optional approximate and binary modes have different rules.
Best use case: Find the relative position of a matching item, including from the end of a list.
Set up the example sheet
Enter A2=Pen, A3=Pad, A4=Pen, and A5=Box. These are product codes from a small transaction log.
Enter the formula in an unused cell. For a formula returning several values, leave an unobstructed area where those values can expand. These formulas use comma argument separators in a typical English-language locale; commas or semicolons inside quoted text are data, not argument separators. Adapt the separator if your regional settings require it.
Worked example 1: XMATCH with known input
=XMATCH("Pad",A2:A5)
Expected output: 2.
Pad is the second value within the searched range A2:A5.
Worked example 2: a second XMATCH case
=XMATCH("Pen",A2:A5,0,-1)
Expected output: 3.
The reverse search finds the last Pen, at the third position in the range, cell A4.
Compare both results before replacing literal values or short sample ranges with your own workbook data. For a spilling formula, compare every output cell, not only the top-left result.
Match modes and a checked approximate lookup
In Excel, match mode 0 is exact matching by default; -1 chooses an exact match or the next smaller value; 1 chooses an exact match or the next larger value; 2 enables wildcard matching. Search mode defaults to 1, from first to last. Binary search modes 2 and -2 require ascending and descending order respectively.
For an independent numeric example, place 10, 20 and 40 in C2:C4:
=XMATCH(25,C2:C4,-1)
=XMATCH(25,C2:C4,1)
Expected positions are 2 and 3, corresponding to 20 and 40. These are positions in the range, not returned price or quantity values. The third argument controls the match rule; it is not the same option as fourth-argument search mode -1.
The official Excel XMATCH reference documents these distinct modes. Expected results are independently calculated, not native Excel observations.
Practical advice and troubleshooting
When this formula helps: Use XMATCH to get a position; wrap it in INDEX when you need an aligned value from another column.
Important edge case: Binary search modes require correctly sorted data; selecting them for unsorted keys can silently return an incorrect answer.
If the result differs, first verify the text-versus-number types of the input cells, the argument separators for your locale, and the range size. For dynamic arrays, inspect occupied cells in the output area. An error that looks like a missing function may reflect a software version rather than incorrect data.
Compatibility and version considerations
Google Sheets also supports XMATCH, documented in its dedicated XMATCH reference. Its omission from the general function catalogue is a catalogue gap, not evidence that the function is unsupported. Check each product’s matching and search options when transferring formulas.
XMATCH is documented for Excel 2021, Excel 2024 and Microsoft 365.
Function availability and parameter behavior must be judged for the specific application and release; a function documented in one spreadsheet does not automatically work in another.
Related guides and official documentation
-
Microsoft Excel documentation for XMATCH — function syntax and current vendor information.
Editorial verification: Vendor catalogue referenced as of 2026-10-12. The two example outputs are independently reasoned; no native application run, screenshot, or version-specific output is claimed. Review the editorial testing standards if you require stronger proof before importing a workbook.