MATCH function in Google Sheets
Returns the relative position of an item in a range that matches a specified value.
=MATCH(search_key, range, [search_type])MATCH syntax and parameters
Three arguments, two required.
- search_keyanyRequired
The value to search for. For example, 42, "Cats", or I24.
- rangerangeRequired
The one-dimensional array to be searched. If a range with both height and width greater than 1 is used, MATCH will return #N/A!.
- search_typenumberOptional
[ OPTIONAL - 1 by default ] - The manner in which to search. 1, the default, causes MATCH to assume that the range is sorted in ascending order and return the largest value less than or equal to search_key. 0 indicates exact match, and is required in situations where range is not sorted. -1 causes MATCH to assume that the range is sorted in descending order and return the smallest value greater than or equal to search_key.
MATCH examples
Formulas you'll actually reuse.
| A | B | C | |
|---|---|---|---|
| 1 | Customer | Region | Amount |
| 2 | Birch & Co | North | 1200 |
| 3 | Acme Corp | West | 4250 |
| 4 | Delta Foods | South | 860 |
| 5 | Corvus Ltd | West | 2975 |
| 6 | Elm Street Bakery | North | 540 |
The position of a customer in the list — 0 means exact match:
=MATCH("Acme Corp", A2:A6, 0)Result
2INDEX MATCH — MATCH finds the row, INDEX returns the amount from it:
=INDEX(C2:C6, MATCH("Acme Corp", A2:A6, 0))Result
4250Two-way lookup — one MATCH picks the row, a second picks the column:
=INDEX(A2:C6, MATCH("Corvus Ltd", A2:A6, 0), MATCH("Region", A1:C1, 0))Result
"West"Partial match with wildcards — * stands for any run of characters, exact-match type only:
=MATCH("*bakery*", A2:A6, 0)Result
5Which tier band a spend amount falls in — type 1 needs ascending thresholds:
=MATCH(4250, {0, 1000, 5000, 20000}, 1)Result
2
MATCH in Excel
Same name — your formula ports as-is.
Try MATCH in the playground
Edit the example — nothing to install.
Preloaded with the MATCH formula from Example 1 — change anything and watch it respond.
MATCH common mistakes
Where it usually goes wrong.
Leaving out the third argument. MATCH then assumes the range is sorted in ascending order and can return the wrong position without any error. Use 0 unless the data really is sorted.
Reading the result as a row number. MATCH returns the position inside the range. A result of 2 for A2:A6 is row 3 of the sheet.
Selecting a block of cells. The range has to be a single row or a single column. Anything wider and taller returns #N/A.
Comparing text with numbers. The text "1200" does not match the number 1200. Convert one side with VALUE or TO_TEXT.
MATCH errors
What they mean — and the fixes.
#N/ANo match — with type 0 the value must match exactly; TRIM stray spaces, and check that numbers aren't stored as text on one side.
Related functions
More ways Google Sheets gets this done.
- INDEXReturns the content of a cell, specified by row and column offset.LookupExcel
- XMATCHReturns the relative position of an item in an array or range that matches a specified value.LookupExcel
- VLOOKUPVertical lookup. Searches down the first column of a range for a key and returns the value of a specified cell in the row found.LookupExcel
- XLOOKUPReturns the values in the result range based on the position where a match was found in the lookup range. If no match is found, it returns the closest match.LookupExcel
- HLOOKUPHorizontal lookup. Searches across the first row of a range for a key and returns the value of a specified cell in the column found.LookupExcel
- LOOKUPLooks through a row or column for a key and returns the value of the cell in a result range located in the same position as the search row or column.LookupExcel