How to Use the HLOOKUP Function in Google Sheets | Search Values in a Horizontal Table
How to Use the HLOOKUP Function
The HLOOKUP (Horizontal Lookup) function searches horizontally across the first (top) row of a specified range and returns the value in a specified row from the column that matches the search key.
Syntax
=HLOOKUP(search_key, range, index, [is_sorted])
- search_key: The value or cell reference to search for in the first row of the range (required).
- range: The cell range to search (required). The
search_keymust be located in the first row of this range. - index: The row number within the range from which to return a value, where the first row is
1(required). - is_sorted: Specifies the search mode (optional). Always specify
FALSE(or0) for an exact match. If omitted, it defaults toTRUE(approximate match).
Example Using a Table
Here is an example of retrieving the “Profit” for “Mar” from the monthly sales master table (A1:E4) below.
[Monthly Sales Master (A1:E4)]
| Row | Column A | Column B (Jan) | Column C (Feb) | Column D (Mar) | Column E (Apr) |
|---|---|---|---|---|---|
| 1 | Item | Jan | Feb | Mar | Apr |
| 2 | Sales | 500,000 | 620,000 | 750,000 | 680,000 |
| 3 | Cost | 300,000 | 350,000 | 410,000 | 380,000 |
| 4 | Profit | 200,000 | 270,000 | 340,000 | 300,000 |
- Formula:
=HLOOKUP("Mar", A1:E4, 4, FALSE) - Result:
340,000(retrieves the Profit in row 4 of Column D, which matches"Mar"in row 1)
Common Errors and Notes
- Value Not Found (
#N/A): If thesearch_keydoes not exist in the first row of the range,#N/Ais returned. Check for full-width/half-width character differences or extra leading/trailing spaces. - Invalid Index (
#REF!/#VALUE!): Specifying anindexgreater than the total number of rows inrange(e.g.,5for a 4-row range) causes a#REF!error, while specifying a number less than1causes a#VALUE!error. - Forgetting
FALSEfor the Fourth Argument: Omitting the fourth argument triggers an approximate match. If the top row of the master table is not sorted in ascending order, it may return a value from an unintended column. Always specifyFALSEfor exact matches.
Frequently Asked Questions
Q. What is the difference between HLOOKUP and VLOOKUP?
A. The search direction is different. VLOOKUP searches vertically down the leftmost column of a table, whereas HLOOKUP searches horizontally across the top row (row 1) and returns a value from a specified row in the same column.
Q. How do I perform an exact match lookup with HLOOKUP?
A. Set the fourth argument (is_sorted) to "FALSE" or "0". Omitting it or setting it to "TRUE" performs an approximate match, which can return incorrect values if the table is not sorted in ascending order.