Google Sheets function · Lookup
HLOOKUP in Google Sheets: syntax and examples
HLOOKUP is VLOOKUP turned sideways. It finds a key in the first row of a range and returns the value from another row of the same column. It fits tables where months or years run across the top.
Syntax
HLOOKUP(search_key, range, index, [is_sorted])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
search_key | any | yes | The value to find in the first row of range. |
range | range | yes | The table to search. The key row must be its top row. |
index | number | yes | Which row of range to return, counted from 1 at the key row. |
is_sorted | boolean | no | FALSE for an exact match. TRUE or omitted means approximate match on a sorted first row. |
Examples
The examples use this table, starting in A1:
| Month | Jan | Feb | Mar |
| Sales | 120 | 95 | 140 |
| Orders | 12 | 9 | 15 |
| Returns | 1 | 0 | 2 |
=HLOOKUP("Feb", A1:D4, 2, FALSE)Result: 95
Sales for February: the key is in the top row, row 2 holds the sales.
Run in a Google Sheet (English US locale) on .
=HLOOKUP("Mar", A1:D4, 3, FALSE)Result: 15
Orders for March, from the third row of the table.
Run in a Google Sheet (English US locale) on .
=IFERROR(HLOOKUP("Apr", A1:D4, 2, FALSE), "no data")Result: no data
A month that is not in the table. IFERROR replaces #N/A with your text.
Run in a Google Sheet (English US locale) on .
=ARRAYFORMULA(HLOOKUP({"Jan", "Mar"}, A1:D4, 4, FALSE))Result:
| 1 | 2 |
Two keys in a row: one result per key, side by side.
Run in a Google Sheet (English US locale) on .
=HLOOKUP("feb", A1:D4, 2, FALSE)Result: 95
The match ignores case, so "feb" finds "Feb".
Run in a Google Sheet (English US locale) on .
Common errors
- The key must sit in the top row of range. A label in the first column, such as "Sales", returns #N/A.
- An index larger than the number of rows in range returns #REF!, for example 5 on a four-row table.
- Without is_sorted the match is approximate and expects a sorted top row. Write FALSE for names and codes.
- If the labels are in a column and the values to the right, use VLOOKUP, or XLOOKUP, which works in both directions.
Compared with Excel
Same arguments as Excel HLOOKUP.