ShareYourGroupShareYourGroupGoogle Sheets

Lookup

INDEX and MATCH functions in Google Sheets

INDEX returns the cell at a position in a range and MATCH finds the position of a value; together they make a flexible lookup.

MATCH tells you where a value is. INDEX tells you what is at a place. Joined, they form a lookup that can search any column and return from any other, and that works in every spreadsheet program.

Syntax

=INDEX(reference, [row], [column])
=MATCH(search_key, range, [search_type])
ArgumentWhat it is
referenceThe range to take a value from.
row, columnThe position inside the range, counting from 1.
search_keyFor MATCH: the value to find.
rangeFor MATCH: one row or one column to search.
search_type0 for an exact match. 1 (the default) for the largest value not above the key in a range sorted upwards. -1 for a range sorted downwards.

Examples

Sample sheet: A small price list with item codes. The table is sorted by code.
ABCDE
1CodeItemCategoryPriceStock
2A101Basmati Rice 5 kgGrocery65040
3A102Toor Dal 1 kgGrocery16075
4B201NotebookStationery60300
5B202Ball PenStationery100
6C301LED BulbElectronics110200
7C302Power BankElectronics129918
8D401Steel BottleHome45055

Step by step

  1. =MATCH("C301", A2:A8, 0) returns 5: the code is the fifth entry.
  2. =INDEX(B2:B8, 5) returns the fifth name.
  3. Put the first inside the second: =INDEX(B2:B8, MATCH("C301", A2:A8, 0)).

The pattern to remember is =INDEX(answer_column, MATCH(key, search_column, 0)).

Always type the 0 in MATCH. Its default assumes sorted data and returns a nearby position on unsorted data, without warning.

Why use it

INDEX with array functions

In Sheets, INDEX has a second life: taking one piece from a result that spills.

Leave the row empty to get a whole column, or the column empty to get a whole row: =INDEX(A2:E8, , 4) is the entire fourth column.

A lesser-known point: a bare INDEX around a formula makes it behave like ARRAYFORMULA, so =INDEX(C2:C9*2) spills too. Many Sheets users type INDEX as a shorter wrapper.

MATCH on its own

Not for self-filling columns

INDEX(..., MATCH(...)) does not expand down a column inside ARRAYFORMULA in the way people expect: INDEX returns a single cell. For a column that fills itself, use VLOOKUP in ARRAYFORMULA, or XLOOKUP.

Common mistakes

In Excel

Both functions are identical in Excel. Excel names MATCH's last argument match_type.

Related functions

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.