Going Stellar

Home/Google Sheets reference

Google Sheets function · Lookup

LOOKUP in Google Sheets: syntax and examples

LOOKUP searches a sorted row or column for the largest value that does not exceed your key. It then returns the item at the same position in a result range. It suits bands such as grades or tax brackets, not exact-match lookups.

Syntax

LOOKUP(search_key, search_range|search_result_array, [result_range])

Arguments

ArgumentTypeRequiredWhat it does
search_keyanyyesThe value to look for. The result belongs to the largest value that is not greater than it.
search_range|search_result_arrayrangeyesA sorted row or column to search, or a two-line array that holds both search and result.
result_rangerangenoThe row or column to return from. It must match the length of the search range.

Examples

The examples use this table, starting in A1:

MinGradeStudentPoints
0FAna87
60DBob45
70CCris72
80BDan95
90AEva60
=LOOKUP(87, A2:A6, B2:B6)

Result: B

87 falls between 80 and 90, so the grade for 80 is returned.

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

=LOOKUP(D2, A2:A6, B2:B6)

Result: B

The same lookup with the key taken from a cell.

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

=ARRAYFORMULA(LOOKUP(D2:D6, A2:A6, B2:B6))

Result:

B
F
C
A
D

A grade for every student from one formula.

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

=LOOKUP(100, A2:A6, B2:B6)

Result: A

A key above the last value returns the last result.

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

=ARRAYFORMULA(LOOKUP(2, 1/(D2:D6>70), C2:C6))

Result: Dan

A classic trick: the last student with more than 70 points. Rows that fail the test become errors and are skipped.

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

Common errors

  • The search range must be sorted ascending. On unsorted data LOOKUP returns a wrong item without an error: on 10, 80, 70 a search for 75 returns the first result, not the one for 70.
  • A key smaller than the first value returns #N/A.
  • A result range shorter than the search range returns #NUM!.
  • A test such as 1/(D2:D6>70) needs ARRAYFORMULA around LOOKUP. Without it the same formula returns #N/A.

Compared with Excel

Same vector form as Excel LOOKUP. The 1/(condition) trick works in Sheets only inside ARRAYFORMULA, while Excel evaluates it directly.

Questions and answers

Should I use LOOKUP or VLOOKUP?

Use VLOOKUP or XLOOKUP for exact keys. LOOKUP fits ranges of thresholds, where the key falls between two values.

Sources

  1. LOOKUP (Docs Editors Help)

Markdown version · All functions