HLOOKUP
About this lesson
HLOOKUP searches the first row of a table for a value. Then it returns a value from the same column, in a row you choose.
- look along a row with HLOOKUP the way VLOOKUP looks down a column.
- recognise a sideways table and choose the right lookup.
The idea
HLOOKUP is VLOOKUP turned sideways, argument for argument. It exists because some tables really are laid out across the page: months, quarters, sizes, years. That is also why it is rare. Most data has one record per row, and when a table grows, it grows downwards.
If you want HLOOKUP on a table that could have been the other way round, the table is the problem, not the lookup. XLOOKUP removes the choice. It takes a lookup range and a return range. They can run either way.
The mistake to watch for
Counting the row number from the sheet instead of from the table. The third argument counts rows inside the range you gave it, heading row included. So a table that starts on row 1 and one that starts on row 3 need different numbers for the same data. Count from the top of the range.
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
HLOOKUP is VLOOKUP turned sideways. It searches the first row of a table and returns a row below it.
In F2, type =HLOOKUP("Mar",B1:E4,2,FALSE).
"Mar" is found along the top row. B1:E4 is the table. 2 is its second row (Occupancy). FALSE means exact match.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Month | Jan | Feb | Mar | Apr | ||
| 2 | Occupancy % | 62 | 58 | 71 | 84 | ||
| 3 | Rooms sold | 558 | 522 | 639 | 756 | ||
| 4 | Avg rate | 89.5 | 91 | 96.25 | 104 | Feb | |
| 5 | |||||||
| 6 | |||||||
| 7 | |||||||
| 8 |
Every step
-
HLOOKUPisVLOOKUPturned sideways. It searches the first row of a table and returns a row below it. InF2, type=HLOOKUP("Mar",B1:E4,2,FALSE). "Mar" is found along the top row.B1:E4is the table. 2 is its second row (Occupancy).FALSEmeans exact match. -
Read
=HLOOKUP("Apr",B1:E4,3,FALSE)and say what it returns. Rooms sold is the third row of the table. -
In
F3, bring back the rooms sold in January, typing the month into the formula. -
The month can come from a cell instead of being typed. That is the version to build.
G4holds a month. InF4, get that month's average rate, the fourth row. -
In
F5, write a formula withHLOOKUPthat works out March's room revenue. That is the rooms sold that month times that month's average rate. Two lookups in one formula.