Excel functions · Lookup
HLOOKUP function in Excel
HLOOKUP looks for a value in the first row of a table and returns the value from a row below it in the same column. It's VLOOKUP turned sideways, for tables where the headers run across the top, such as months or quarters.
Last reviewed
Syntax
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])- lookup_valuerequired
- The value to find in the first row of table_array.
- table_arrayrequired
- The table to search. Its first row is the one searched.
- row_index_numrequired
- Which row of table_array to return. Row 1 is the header row you search in, so data starts at 2.
- range_lookupoptional
- FALSE for an exact match. TRUE, or left out, is an approximate match that needs the first row sorted.
- Like VLOOKUP, it defaults to approximate match, so end it with FALSE.
- XLOOKUP does the same job on a row and doesn't need a row number: =XLOOKUP("Q3", B1:E1, B2:E2).
Which versions have HLOOKUP
Every current Excel version: Microsoft 365, Excel for the web, Excel 2024, 2021, 2019 and 2016, on Windows and Mac.
| Version | Has it |
|---|---|
| Microsoft 365 (Windows and Mac) | Yes |
| Excel for the web | Yes |
| Excel 2024 | Yes |
| Excel 2021 | Yes |
| Excel 2019 | Yes |
| Excel 2016 | Yes |
Google Sheets
Google Sheets has HLOOKUP with the same arguments and the same approximate-match default.
Examples
The examples use this sample sheet.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Metric | Q1 | Q2 | Q3 | Q4 |
| 2 | Revenue | 42000 | 45500 | 39800 | 51200 |
| 3 | Orders | 310 | 335 | 298 | 362 |
1.Revenue for one quarter
=HLOOKUP("Q3", A1:E3, 2, FALSE)Result: 39800
Q3 is found in row 1; row 2 of the table is Revenue.
2.Orders for another quarter
=HLOOKUP("Q4", A1:E3, 3, FALSE)Result: 362
Row 3 of the table is Orders.
3.Handle a missing quarter
=IFERROR(HLOOKUP("Q5", A1:E3, 2, FALSE), "No data")Result: No data
There's no Q5, so HLOOKUP returns #N/A and IFERROR swaps it for a message.
Common errors and fixes
| Error | Why it happens | Fix |
|---|---|---|
| #N/A | The value isn't in the first row of table_array. | Check spelling and spaces in the header, or wrap the formula in IFERROR. |
| #REF! | row_index_num is bigger than the number of rows in table_array. | Extend table_array down or use a smaller row number. |
Do it with GPTExcel
Skip writing HLOOKUP by hand
Upload your Excel or CSV file to Chat and ask in plain English. GPTExcel writes the formula for your file and your version of Excel or Google Sheets.
From my monthly KPI sheet, pull last quarter's revenue and order count into a summary.
Done. I used HLOOKUP on your sheet and checked the results against your data.
- Written for your platform and version
- Checked against your actual data
- Newest functions looked up in official docs
HLOOKUP questions
- What's the difference between HLOOKUP and VLOOKUP?
- VLOOKUP searches down the first column and returns from a column to the right. HLOOKUP searches across the first row and returns from a row below. Choose the one that matches how your headers run.
- Does row_index_num count the header row?
- Yes. Row 1 is the first row of table_array, the one being searched, so the first data row below it is 2.
Skip the formula hunt
Upload a spreadsheet and ask in plain English. Free plan, no credit card.
Start free