Hlookup
HLOOKUP Function¶
The HLOOKUP function in Excel is used for horizontal lookup. It searches for a specified value in the top row of a table or range and returns a value in the same column from a specified row.
Syntax:¶
HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
- lookup_value: The value to search for in the first row of the table or range.
- table_array: The range of cells containing the data to be searched.
- row_index_num: The row number in
table_arrayfrom which to retrieve the value. For example,2would return a value from the second row oftable_array. - range_lookup (optional): A logical value that specifies whether to look for an exact match or an approximate match.
- If
TRUEor omitted,HLOOKUPwill look for the nearest match tolookup_value. This requires the first row oftable_arrayto be in ascending order. - If
FALSE,HLOOKUPwill look for an exact match. If multiple values match, the first one found is used.
Examples:¶
=HLOOKUP("Apple", A1:D2, 2, FALSE)would search for "Apple" in the first row ofA1:D2. If found, it returns the value from the second row in the same column.=HLOOKUP(3, E1:H4, 4, TRUE)might search for the value3in the first row ofE1:H4and return the corresponding value from the fourth row. If the exact value is not found, it will return the nearest match.=HLOOKUP("Quarter 1", {"Quarter 1","Quarter 2","Quarter 3","Quarter 4";100,150,200,175}, 2, FALSE)would search for "Quarter 1" in the array and return100from the second row.
Note: Where an array is used: {"Quarter 1","Quarter 2","Quarter 3","Quarter 4";100,150,200,175} then this does not create a table, but instead is put in memory. This is compatible with WASM.
Usage Notes:¶
HLOOKUPis useful for data organized horizontally, where the lookup value is in a row at the top of the data set.- It's important to ensure that the data in the first row is sorted when using approximate match (
TRUEor omitted forrange_lookup).
Note:
HLOOKUPis less commonly used thanVLOOKUP, which performs a vertical search. For more complex lookups, or when dealing with unsorted data, consider using theINDEXandMATCHfunctions together, or the newerXLOOKUPfunction in Excel 365 and Excel 2019.Note: When range_lookup is TRUE, Codcel will automatically order the first row in your table_array in ascending order. This may give different results to Excel, if the table is not ordered correctly in Excel.
Note: The first row must not contain functions, if it does the search may not work correctly.