Excel function

XMATCHfunction

Returns the position of a value in a range. Exact match is the default, and it can search from the bottom.

Excel 2021+
=XMATCH("Eggs", B2:B9)
12345678
A
B
C
D
1
2
3
4
5
6
7
8
9

Click a cell to change lookup_value. Drag the corner dots to change lookup_array. Enter "?ilk" for lookup_value and switch match_mode to 2 (wildcard). Try breaking it on purpose to see the errors.

Result

4

lookup_value

The value to find in the range.

lookup_array
B2:B9Drag a corner dot up/down to resize, sideways to change the column

The column to search. The numbers on the left are positions within the range.

match_mode

Omitted means 0 (exact match). Unlike MATCH, it finds approximate matches without sorting.

search_mode

Which position to return when the same value appears more than once.

What is the XMATCH function?

=XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])

XMATCH returns the position of a value in a range. It is the newer version of MATCH, and when omitted it looks for an exact match.

It supports searching from the bottom (search_mode -1), approximate matches that need no sorting, and wildcards. Watch the range compared cell by cell above.

Arguments

lookup_value
The value to find in the range.
lookup_array
The column or row to search.
match_mode
0 (omitted) exact; -1 next smaller if none; 1 next larger if none; 2 wildcard.
search_mode
1 (omitted) from first to last; -1 from last to first.

XMATCH examples

  1. Example 1. Find a position

    =XMATCH("Eggs", B2:B9)

    4.

  2. Example 2. With INDEX

    =INDEX(C2:C9, XMATCH("Eggs", B2:B9))

    Returns the price of Eggs, 6900.

  3. Example 3. Wildcard

    =XMATCH("?ilk", B2:B9, 2)

    The position of "Milk", 2.

Common mistakes

FAQ

Is the result a row number?
No. It is the position within the range; the first cell of B2:B9 is 1.
What if it is not found?
You get #N/A. You can wrap it in IFERROR.