The HLOOKUP function in Google Sheets is a powerful tool designed for horizontal lookups. This function allows users to search for a specific value in the first row of a defined range and return a value from a specified row in the identified column. This feature is particularly useful for organizing and extracting data efficiently when working with horizontal data sets.
Syntax
HLOOKUP(search_key, range, index, [is_sorted])
- search_key: The value you want to search for in the first row of the range.
- range: The two-dimensional range of cells where the search will take place.
- index: The row number in the range from which to return the value, counted from the top of the range.
- [is_sorted]: (Optional) A boolean value indicating whether to find an approximate match (TRUE) or an exact match (FALSE). Default is TRUE.
Example #1
=HLOOKUP("Sales", A1:D4, 3, FALSE)
This function searches for the term “Sales” in the first row of the range A1:D4 and returns the value from the third row of the corresponding column. For example, if Sales is found in column B, it would return the value from B3.
Result: 1500
Example #2
=HLOOKUP("Q3", A1:E2, 2, TRUE)
Here, the function looks for the key “Q3” in the first row of the range A1:E2 and returns the value from the second row of the matching column. If Q3 is found in column C, it retrieves that corresponding value.
Result: 2000
Example #3
=HLOOKUP("Profit", A2:E10, 3, FALSE)
In this case, the function searches for “Profit” across the first row of the specified range and returns the value from the third row of the matching column. If Profit is located in column E, the value from E3 will be returned.
Result: 800
Error handling
- N/A: This error occurs if the search_key is not found in the first row of the range.
- VALUE!: Indicates an issue with the provided parameters, such as a non-integer for the index or range sizes that are incompatible.
- REF!: This error indicates that the index is greater than the number of rows in the specified range.