Lookup function
MATCH function in Google Sheets and Excel
MATCH returns the position of a value in a single row or column: 1 for the first cell, 2 for the second, and so on.
Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
Syntax
MATCH(lookup_value, lookup_array, [match_type])Arguments in [brackets] are optional. Google Sheets writes it MATCH(search_key, range, [search_type]).
Example
=MATCH(M1,H2:H8,0) reads: Find where the product in M1 sits in the product list H2:H8, exact match only.
| A | B | C | D | E | F | G | H | I | J | K | L | M | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Order | SKU | Qty | SKU | Product | Price | Stock | Product | Fern | ||||
| 2 | 2001 | PL-104 | 2 | PL-101 | Fern | $9.50 | 40 | Position | 1 | ||||
| 3 | 2002 | PT-210 | 1 | PL-104 | Monstera | $34.00 | 12 | ||||||
| 4 | 2003 | TL-301 | 3 | PL-107 | Snake plant | $22.00 | 25 | ||||||
| 5 | 2004 | PL-101 | 1 | PT-210 | Terracotta pot | $12.50 | 60 | ||||||
| 6 | 2005 | SL-401 | 4 | PT-212 | Ceramic pot | $19.00 | 18 | ||||||
| 7 | 2006 | PL-104 | 1 | TL-301 | Watering can | $18.00 | 9 | ||||||
| 8 | 2007 | PT-212 | 2 | SL-401 | Potting mix | $7.25 | 80 | ||||||
| 9 | 2008 | PL-107 | 1 |
M2 shows 1: Fern is the first product in H2:H8.
How the spreadsheet calculates it
Finds the position of M1 in H2:H8 (1 = the first cell). 0 means exact match.
- 1. MATCH: Finds the position of
M1inH2:H8(1 = the first cell).0means exact match.key=`M1`: what to findrange=`H2:H8`: one column or row to search0=`0`: exact match. Leave it out and MATCH assumes sorted data
More MATCH examples
=MATCH(F2,$A$2:$A$9,0)The position of F2 in the list, exact match.=ISNUMBER(MATCH(D2,$H$2:$H$4,0))TRUE when D2 is one of the allowed values in H2:H4.=MATCH("Price",$A$1:$F$1,0)Which column of the header row says Price.=MATCH(D2,$G$2:$G$6,1)The band a score falls in, on boundaries sorted ascending.
Paste any of these into the formula explainer to see it step by step.
Tips
- Write
0as the third argument unless you deliberately want an approximate match on sorted data. - Wrap it in ISNUMBER to turn “found or not” into TRUE or FALSE for checks and conditional formatting.
- Search a header row with MATCH to find a column by its name instead of hard-coding its number.
- With 0 as match type, MATCH accepts wildcards:
MATCH("Fern*", H2:H8, 0)finds the first product starting with Fern.
What MATCH is used for
Finding which row a key is on for INDEX, checking whether a value exists in a list (with ISNUMBER), and finding which column a header is in so a formula follows the table when columns move.
Arguments
| Argument | Required | What it is |
|---|---|---|
| lookup_value | Yes | The value to find. |
| lookup_array | Yes | One row or one column to search. |
| match_type | No | 0 for an exact match. Left out, it's 1: the largest value less than or equal, on data sorted ascending. -1 is the smallest value greater than or equal, on data sorted descending.Watch out: Leaving it out on unsorted data returns wrong positions. |
Common mistakes
Leaving out the 0: MATCH then looks for the nearest smaller value in sorted data.
Expecting a row number on the sheet: MATCH returns the position inside the range.
Searching a two-dimensional range: MATCH needs a single row or column.
In Google Sheets
Google Sheets has MATCH with the same arguments and the same default (1, approximate) when the last one is left out. It doesn't have XMATCH.
Errors you may see with MATCH
- #N/A: The value isn't in the range (or differs by type or spaces). How to fix it.
Questions
MATCH or XMATCH?
MATCH works in every Excel version and Google Sheets; XMATCH defaults to exact match and can search from the end but needs Excel 2021 or later. See MATCH vs XMATCH.
Is MATCH case-sensitive?
No. To match case, use MATCH(TRUE, EXACT(range, value), 0).
What does #N/A from MATCH mean?
The value isn't in the range with that match type. With 0, it means no exact match: check for spaces and numbers stored as text.
Sources
Official documentation the facts on this page were checked against.