formulastreak

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

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.

Orders and price list · edit M2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultM2 = 1
ABCDEFGHIJKLM
1OrderSKUQtySKUProductPriceStockProductFern
22001PL-1042PL-101Fern$9.5040Position1
32002PT-2101PL-104Monstera$34.0012
42003TL-3013PL-107Snake plant$22.0025
52004PL-1011PT-210Terracotta pot$12.5060
62005SL-4014PT-212Ceramic pot$19.0018
72006PL-1041TL-301Watering can$18.009
82007PT-2122SL-401Potting mix$7.2580
92008PL-1071

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. 1. MATCH: Finds the position of M1 in H2:H8 (1 = the first cell). 0 means exact match.
    • key = `M1`: what to find
    • range = `H2:H8`: one column or row to search
    • 0 = `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 0 as 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

ArgumentRequiredWhat it is
lookup_valueYesThe value to find.
lookup_arrayYesOne row or one column to search.
match_typeNo0 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

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.

Practise MATCH on a live sheet

Lesson 16, INDEX and MATCH (Unit 4, Lookups), has 5 graded exercises, checked instantly, with steps and hints when you're stuck. Pro