What is the HLOOKUP function?
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])HLOOKUP finds a value in the first row of a table and then returns a value from a lower row in the same column. The H stands for horizontal; think of it as VLOOKUP turned on its side.
Use it for tables with items laid out across, such as monthly results or grading scales. If the values you search are listed down the left column, use VLOOKUP; if they run across the top row, use HLOOKUP.
The most important rule is the same as VLOOKUP: HLOOKUP always searches only the first row of table_array.
Arguments
- lookup_value
- The value to find in the first row of table_array. Text is not case-sensitive.
- table_array
- The table to search. The row containing lookup_value must be the first row of this range, and the row you want to return must be inside it.
- row_index_num
- Which row of table_array to return, counting the first row of the range as 1 rather than using the sheet row number. Below 1 gives #VALUE!; more than the rows in table_array gives #REF!.
- range_lookup
- FALSE finds only an exact match. TRUE or omitted uses approximate match: with no exact match it takes the largest value smaller than lookup_value, and the first row must be sorted in ascending order from left to right.
HLOOKUP examples
Example 1. Price by product code
=HLOOKUP("P004", B1:F4, 3, FALSE)Finds P004 in row 1 and returns row 3 of table_array (Price) in the same column: 6900. This is how the sheet looks when the page opens.
Example 2. Stock by product name
=HLOOKUP("Coffee", B2:F4, 3, FALSE)Starting table_array at row 2 makes the product names the first row, so you can search by name. Row 3 of the range is sheet row 4 (Stock), so the result is 15.
Example 3. Grades with approximate match
=HLOOKUP(85, B1:F2, 2, TRUE)List the starting score of each band in the first row in ascending order. There is no 85, so it takes 80, the largest value below 85, and returns the B underneath.
Common mistakes
The value is not in the first row of table_array
If you search by product name but table_array starts at the code row, you get #N/A. Set table_array so that the row with lookup_value is the first row. HLOOKUP cannot return values above the first row.
Leaving out range_lookup
Without the fourth argument it uses approximate match (TRUE). If the first row is not sorted, you can get a wrong value with no error, so always write FALSE for an exact search.
Counting row_index_num as the sheet row
If table_array is B2:F4, sheet row 4 is row_index_num 3. Drag the top handle of table_array down above and watch the numbers on the left change.
FAQ
- How is it different from VLOOKUP?
- Only the direction. VLOOKUP searches the first column from top to bottom and returns a value from a column to the right; HLOOKUP searches the first row from left to right and returns a value from a row below.
- Can XLOOKUP replace it?
- Yes. With a one-row lookup array and return array, XLOOKUP searches horizontally too. XLOOKUP is available only in Microsoft 365 and Excel 2021 and later.
- When do #REF! and #VALUE! appear?
- row_index_num below 1 gives #VALUE!, and more than the rows in table_array gives #REF!. Click the numbers on the left of the sheet above to try it.