Function · Lookup
Excel MATCH function
The Excel MATCH function returns the position of a value in a list. Exact match needs a third argument of 0. An oat-milk example.
Syntax =MATCH(lookup_value, lookup_array, [match_type])
=MATCH("Oat milk",A2:A5,0)Arguments
| Name | Required | What to pass |
|---|---|---|
| lookup_value | Required | The value to find. |
| lookup_array | Required | A single row or a single column to search. |
| match_type | Optional | 0 is an exact match. 1, the default, is the largest value less than or equal to the lookup, and the range must be sorted ascending. -1 is the smallest value greater than or equal, sorted descending. |
Examples
Where oat milk sits in the price list
=MATCH("Oat milk",A2:A5,0)Result 3
| A | B | C | |
|---|---|---|---|
| 1 | Item | Price | Position of oat milk |
| 2 | Whole milk | 3.49 | 3 |
| 3 | Eggs | 4.29 | |
| 4 | Oat milk | 4.79 | |
| 5 | Bread | 3.19 |
MATCH returns a position, not the cell’s contents. Oat milk is the third item, so the result is 3. Feed that 3 to INDEX when you want the price. The position is counted inside the range, starting at 1. It is not the sheet’s row number. A2 is position 1 of A2:A5 even though it is row 2 of the sheet.
The third argument defaults to 1. That form expects the list to be sorted ascending and returns the closest item that is not greater than what you asked for. On a list of product names it will quietly return the wrong row. Pass 0 for an exact match.
XMATCH is the newer version, with the same ideas as XLOOKUP. Use MATCH when the file still has to open in Excel 2019 or earlier.