Going Stellar

Home/Google Sheets reference

Google Sheets function · Lookup

INDEX in Google Sheets: syntax and examples

INDEX reads one cell, a row or a column from a range by position. Paired with MATCH it replaces VLOOKUP and can look in any direction.

Syntax

INDEX(reference, [row], [column])

Arguments

ArgumentTypeRequiredWhat it does
referencerangeyesThe range to read from. Row and column numbers count inside it.
rownumbernoRow position inside reference, from 1. 0 or omitted returns whole columns.
columnnumbernoColumn position inside reference, from 1. 0 or omitted returns whole rows.

Examples

The examples use this table, starting in A1:

ProductPriceStock
Lamp8012
Chair5490
Stand1307
Tray3440
=INDEX(A2:C5, 3, 2)

Result: 130

Third row, second column of the block: the price of Stand.

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

=INDEX(B2:B5, 2)

Result: 549

With a single column the row number is enough.

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

=INDEX(A2:A5, MATCH(34, B2:B5, 0))

Result: Tray

MATCH finds the row of price 34, INDEX returns the product from that row. This also looks left, which VLOOKUP cannot do.

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

=INDEX(A2:C5, 0, 2)

Result:

80
549
130
34

Row 0 means every row: the whole second column comes back as an array.

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

=INDEX(A2:C5, 2, 0)

Result:

Chair5490

Column 0 means every column: the whole second row spills across.

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

Common errors

  • A row or column number outside the range returns #NUM!, for example row 5 on a four-row range.
  • INDEX counts from the first cell of reference, not from the sheet. In B2:B5, row 1 is B2.
  • When MATCH cannot find the key, the whole INDEX/MATCH formula returns #N/A. Use 0 as MATCH's last argument for an exact match, and wrap in IFERROR.
  • Row 0 or column 0 returns a whole column or row as an array, which spills and needs empty cells.

Compared with Excel

Same syntax as Excel INDEX for a single range. Excel's extra area_num argument for several areas is not in Sheets.

Questions and answers

Why use INDEX and MATCH instead of VLOOKUP?

The key column can be anywhere, including right of the result, and inserting columns does not shift a hard-coded index number.

Sources

  1. INDEX (Docs Editors Help)

Markdown version · All functions