The HLOOKUP function
HLOOKUP is VLOOKUP turned on its side. It looks along the top row of a table for a value, then reads *down* to another row in the same column.
Use it when your headings run across the page, such as sizes, months or years. As with VLOOKUP, end the formula with FALSE for an exact match.
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Arguments
- lookup_value
- What to look for in the first row of the table.
- table_array
- The table to search, starting with the row that holds the lookup values.
- row_index_num
- Which row of the table to return: 1 is the top row, 2 the next, and so on.
- range_lookupoptional
- FALSE for an exact match. TRUE, or leaving it out, finds the nearest value below in a sorted row.
Try it
=HLOOKUP(B5,B1:E3,3,FALSE) in B6. HLOOKUP finds L in the top row of B1:E3, then goes down to the 3rd row of the table: £14.00.
B6
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Size | S | M | L | XL | |
| 2 | Chest (cm) | 86 | 96 | 106 | 116 | |
| 3 | Price | £12.00 | £12.00 | £14.00 | £15.00 | |
| 4 | ||||||
| 5 | Size wanted | L | ||||
| 6 | Price | £14.00 | ||||
| 7 | ||||||
| 8 |
Edit the formula in B6, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =HLOOKUP("M",B1:E3,2,FALSE) | 96 | Row 2 of the table holds the chest measurement. |
| =HLOOKUP("XL",B1:E3,3,FALSE) | £15.00 | The last column works the same way. |
| =HLOOKUP("XXL",B1:E3,3,FALSE) | #N/A | There's no XXL in the top row. |
Tips
- Count rows from the top of
table_array, not from row 1 of the sheet. - XLOOKUP works across rows too, and doesn't need a row number:
=XLOOKUP(B5,B1:E1,B3:E3). - Lock the table with
$B$1:$E$3before copying the formula.
Common mistakes
- The wrong column's value comes back with no error.The last argument is missing, so HLOOKUP did an approximate match on an unsorted row. Add
FALSE. - #REF! appears.
row_index_numis larger than the number of rows in the table range. - You used HLOOKUP on a list that runs downwards.HLOOKUP searches across the top row. For a list down a column, use VLOOKUP or XLOOKUP.
Practise HLOOKUP with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.