Skip to content

HLOOKUP

Searches the top row of a table for a value and returns the item from another row of the same column. It is VLOOKUP turned on its side.

Syntax

=HLOOKUP(, , , )

Lookup and reference

Every version of Excel, including Microsoft 365, Excel 2024, 2021, 2019, 2016 and earlier, Excel for the web and the mobile apps.

Try it

Edit the formula in B7 or change the inputs. The sheet recalculates as you type.

B7
A
B
C
D
E
F
1
Measure
Jan
Feb
Mar
Apr
2
Units sold
410
385
462
498
3
Revenue
24,600
23,100
27,720
29,880
4
Returns
12
9
15
11
5
6
Month
Revenue
7
Mar
27,720
8
9

B7 =HLOOKUP(A7,A1:E4,3,FALSE) returns 27,720

How HLOOKUP works

HLOOKUP looks across the top row of a table for a value and returns the item from another row in the same column. It is VLOOKUP turned on its side, built for tables where the headers run across the page, such as months or quarters in row 1 and one line per measure underneath.

The four arguments

  • lookup_value is what you are searching for. Point at a cell rather than typing the value.
  • table_array is the block that holds the header row and the rows below it. HLOOKUP always searches the top row of this block, so the range must start on the header row.
  • row_index_num is the position of the row to return, counted from the top of table_array. 1 is the header row itself, 2 is the row below it, and so on. A number larger than the table is tall returns #REF!.
  • range_lookup chooses the match type. FALSE (or 0) is an exact match. TRUE, or leaving the argument out, is an approximate match.

Exact or approximate

As with VLOOKUP, the default is approximate. It assumes the top row is sorted ascending and returns the column whose header is the largest value not above your lookup value. That suits numeric bands laid out across a row, such as discount tiers by order size. For text headers such as month names or product codes, type FALSE. Month names aren't sorted alphabetically, so an approximate match on them returns wrong answers without any error.

An exact match returns the first match from the left, ignores case, and accepts the wildcards * and ? in text.

When to use something else

HLOOKUP shares every weakness of VLOOKUP, turned sideways. The row number is a hard-coded count, so inserting a row inside the table can silently change the result. It can't return a row above the header row. And the approximate default catches people out.

INDEX with MATCH works in every version of Excel and has none of those limits. XLOOKUP handles horizontal data too: point lookup_array at the header row and return_array at the row you want, and the result survives inserted rows. It needs Excel 2021 or Microsoft 365.

If the data is yours to lay out, put headers across the top only when the table is short and meant to be read like a report. Long lists are easier to filter, sort and total when the headers run down the first column of a normal table, and then VLOOKUP, XLOOKUP and the rest of the lookup family work without surprises.

Handling a missing value

An exact HLOOKUP returns #N/A when the header isn't in the top row. Wrap it in IFNA to show a message instead: =IFNA(HLOOKUP(B10,A1:F4,3,FALSE),"No such month").

Arguments

lookup_value
What to look for in the top row of the table, such as B10. Point at a cell rather than typing the value.
table_array
The block that holds the header row and the rows you want back, such as A1:F4. HLOOKUP always searches the top row of this block.
row_index_num
The position of the row to return, counted from the top of table_array: 1 is the search row, 2 the next one. A number larger than the table is tall returns #REF!. A number below 1 returns #VALUE!.
range_lookupoptional
FALSE (or 0) finds an exact match and returns #N/A if there is none. TRUE (or leaving it out) finds an approximate match: the largest value that is less than or equal to lookup_value, which only works if the top row is sorted ascending.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Exact match: find a cost in a table with months across the top

B7 =HLOOKUP(A7,A1:E4,3,FALSE)

Result: 27,720

HLOOKUP finds Mar in the top row of A1:E4 and returns the value from the third row of that column. FALSE asks for an exact match.

B7
A
B
C
D
E
F
1
Measure
Jan
Feb
Mar
Apr
2
Units sold
410
385
462
498
3
Revenue
24,600
23,100
27,720
29,880
4
Returns
12
9
15
11
5
6
Month
Revenue
7
Mar
27,720
8
9

B7 =HLOOKUP(A7,A1:E4,3,FALSE) returns 27,720

Example 2

Choose the row by its label with MATCH

C7 =HLOOKUP(A7,A1:E4,MATCH(B7,A1:A4,0),FALSE)

Result: 11

MATCH finds Returns in the first column and returns 4, so HLOOKUP returns the fourth row. If a row is inserted into the table, MATCH still points at the right one.

C7
A
B
C
D
E
F
1
Measure
Jan
Feb
Mar
Apr
2
Units sold
410
385
462
498
3
Revenue
24600
23100
27720
29880
4
Returns
12
9
15
11
5
6
Month
Measure
Value
7
Apr
Returns
11
8
9
10

C7 =HLOOKUP(A7,A1:E4,MATCH(B7,A1:A4,0),FALSE) returns 11

Example 3

Approximate match: a discount tier by order size

B5 =HLOOKUP(A5,B1:E2,2,TRUE)

Result: 6%

640 isn't in the top row, so the approximate match drops to the largest value not above it: 500, which carries a 6% discount. The top row is sorted ascending, which an approximate match requires.

B5
A
B
C
D
E
F
1
Order from (units)
0
100
500
1000
2
Discount
0%
3%
6%
10%
3
4
Units ordered
Discount
5
640
6%
6
7
8

B5 =HLOOKUP(A5,B1:E2,2,TRUE) returns 6%

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B7, return the number of late deliveries for the month in A7. Ask for an exact match.

Answer in B7.

B7
A
B
C
D
E
F
1
Measure
Jan
Feb
Mar
Apr
2
Orders
188
164
203
221
3
Late deliveries
14
9
17
12
4
Refunds
6
4
9
5
5
6
Month
Late deliveries
7
Mar
8
9
Month
Refunds
10
Feb
11

Common mistakes

  • Leaving out the fourth argument runs an approximate match. On text headers such as month names it can return the wrong column without an error. Type FALSE unless the top row holds sorted numbers.
  • The row number is a count, not a reference. Inserting a row inside table_array shifts the count and can return the wrong row silently. Find the number with MATCH on the row labels, or use XLOOKUP.
  • #N/A on an exact match means the value isn't in the top row of table_array. Check for stray spaces, a number stored as text, and whether the range starts on the header row.
  • The table range slides when you fill the formula down or across. Lock it with dollar signs, such as $A$1:$E$4.
  • HLOOKUP can't return a row above the header row. Use INDEX/MATCH or XLOOKUP when the answer sits above the headers.

Questions people ask

What is the difference between VLOOKUP and HLOOKUP?

VLOOKUP searches the first column of a table and returns a column. HLOOKUP searches the top row and returns a row. The arguments and match modes are otherwise the same.

Why does HLOOKUP return #REF!?

The row_index_num is larger than the number of rows in table_array. A table with four rows can return rows 1 to 4 only. Count the rows in your range, or find the row number with MATCH.

Does HLOOKUP work in a table with headers down the side?

No. HLOOKUP searches across the top row. If your headers run down the first column, use VLOOKUP or XLOOKUP instead.

Is XLOOKUP a better choice than HLOOKUP?

In Excel 2021 and Microsoft 365, yes. XLOOKUP matches exactly by default, points at the row you want instead of counting, and keeps working when rows are inserted. Use HLOOKUP only when the file must open in Excel 2019 or earlier, and even then INDEX/MATCH is safer.

Learn HLOOKUP in a real sheet.

HLOOKUP is taught in Lookups and references, lesson 13: HLOOKUP for horizontal tables. Each lesson is a short, graded exercise like the one above.