Going Stellar

Home/Google Sheets reference

Google Sheets function · Lookup

MATCH in Google Sheets: syntax and examples

MATCH looks for a key in one row or column and returns its position, counted from 1. It rarely works alone: INDEX turns that position into a value. Put 0 as the last argument when you want an exact match.

Syntax

MATCH(search_key, range, [search_type])

Arguments

ArgumentTypeRequiredWhat it does
search_keyanyyesThe value to find. Text, number or a cell reference.
rangerangeyesOne row or one column to search in. A two-dimensional range gives #N/A.
search_typenumberno0 for an exact match. 1 (default) finds the largest value that is not above the key, on ascending data. -1 does the opposite on descending data.

Examples

The examples use this table, starting in A1:

SKUProductPriceStock
A-100Desk lamp3412
A-200Office chair79.90
B-300Monitor stand129.57
B-400Cable tray54940
=MATCH("B-300", A2:A5, 0)

Result: 3

Position of a SKU in the list. 0 means exact match.

Run in a Google Sheet (English US locale) on .

=MATCH(100, C2:C5, 1)

Result: 2

Approximate match on ascending prices: the largest price not above 100 is 79.9, in position 2.

Run in a Google Sheet (English US locale) on .

=MATCH("B-*", A2:A5, 0)

Result: 3

A wildcard with exact mode finds the first code that starts with B-.

Run in a Google Sheet (English US locale) on .

=INDEX(B2:B5, MATCH("B-400", A2:A5, 0))

Result: Cable tray

The classic pair: MATCH gives the row, INDEX returns the product from it.

Run in a Google Sheet (English US locale) on .

=MATCH("b-300", A2:A5, 0)

Result: 3

Lowercase key against uppercase data still matches: the search ignores case.

Run in a Google Sheet (English US locale) on .

Common errors

  • Leaving search_type out means 1, an approximate match that assumes ascending data. On unsorted data it can return a wrong position with no error.
  • A key that is not found gives #N/A. With 1, the same happens when the key is smaller than the first item.
  • The range must be a single row or column. A two-column range such as A2:B5 returns #N/A, even if the key is there.
  • Wildcards (* and ?) only work with search_type 0. With 1, the key "B-*" is not expanded and returns 2 instead of 3. A key that contains a literal * needs ~ in front of it.

Compared with Excel

MATCH takes the same three arguments in Excel and defaults to 1 there too.

Sources

  1. MATCH (Docs Editors Help)

Markdown version · All functions