HLOOKUP
Look up a value in the top row of a table and return a value from the same column with HLOOKUP.
Spreadsheet editor
Spreadsheet editor
Syntax
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Returns: Varies Arguments
| Argument | Required | Description |
|---|---|---|
| lookup_value | Yes | The value to find in the top row of the table. |
| table_array | Yes | The range of cells that holds the data, with the values to search in the top row. |
| row_index_num | Yes | The row number inside table_array to return a value from. The top row is 1, the next row down is 2, and so on. |
| range_lookup | No | TRUE (or omitted) finds the closest match and needs the top row sorted ascending. FALSE finds an exact match. |
About
Use HLOOKUP when you want to pull a figure that lines up with a label in the header row. Common cases include grabbing a month's total from a budget laid out across columns or finding a rate from a horizontal lookup table. By default HLOOKUP does an approximate match, which expects the top row sorted in ascending order, so add FALSE as the last argument when you need an exact match (most often the case).
Most data is laid out with headers down the left side instead, where VLOOKUP is the better fit. If your spreadsheet supports it, XLOOKUP handles both directions and is more forgiving, while INDEX and MATCH give you a flexible two-step alternative.
Exercises using HLOOKUP
Examples
Find a commission rate from a tiered table
Spreadsheet editor
Why you need FALSE for an exact match
Spreadsheet editor
Pick the row dynamically with MATCH
Spreadsheet editor
Watch out for
Forgetting FALSE for an exact match
Leaving off the last argument makes HLOOKUP do an approximate match. On unsorted data that quietly returns the wrong value instead of an error, which is easy to miss.
→ Add FALSE as the fourth argument whenever you need an exact match, like looking up a name, code, or label. Only use TRUE when your top row is sorted ascending and you want the closest match.
Counting row_index_num from the worksheet
row_index_num counts rows inside table_array, not the worksheet row numbers. If your table starts on row 5, asking for row 3 still means the third row of the range.
→ Count down from the top of your selected table: the header row is 1, the row below it is 2, and so on. A number larger than the table's height returns a #REF! error.
Approximate match on an unsorted top row
With range_lookup set to TRUE, HLOOKUP assumes the top row is sorted in ascending order. An unsorted row gives results that look random.
→ Sort the top row from smallest to largest before using TRUE, or switch to FALSE for an exact match where sort order does not matter.