The Excel HLOOKUP Function (2024)

Home »Excel-Built-In-Functions »Excel-Lookup-And-Reference-Functions »Excel-Hlookup-Function

Related Functions:

LOOKUP Function
VLOOKUP Function

Function Description

The Excel Hlookup function 'looks up' a given value in the top row of a data array (or table),and returns the corresponding value from another row of the array.

The syntax of the function is:

HLOOKUP( lookup_value, table_array, row_index_num, [range_lookup] )

Where the function arguments are as follows:

lookup_value-The value that you want to search for, in the first row of the supplied data array.
table_array-The data array or table, containing the data to be searched in the top row, and thereturn values in any other row.
row_index_num-The row number, within the supplied table_array, that youwant the corresponding value to be returned from.
[range_lookup]-An optional logical argument, which can be set to TRUE or FALSE, meaning:
TRUE-

if the function cannot find an exact match to the supplied lookup_value,it should use the closest match below the supplied value.

Note: If [range_lookup] is set to TRUE,the top row of the table_array must be in ascending order.

FALSE-if the function cannot find an exact match to the supplied lookup_value,it should return an error.

Wildcards

In text-related Hlookups, when the [match_type] argument is set to 0, thelookup_value can contain the following wildcard characters:

? - matches any single character
* - matches any sequence of characters

Hlookup Function Examples

Hlookup Example 1 - Exact Match Lookup

Cells A2-F6 of the spreadsheet below, show the exam scores for 5 students in 4 different subjects.If you want to look up a specific score (e.g. Biology) for one of the students (e.g. Ed), this canbe done using the Hlookup function, as shown in cell B10 of the spreadsheet.

Formulas:

The Excel HLOOKUP Function (1)

Results:

The Excel HLOOKUP Function (2)

In the above example, the Hlookup function searches through the top row of thetable_array (the range A2-F2), to find a match for thelookup_value (the name "Ed"). When the name "Ed" is found, thefunction returns the corresponding value from the 5th row of the table_array.

The Excel HLOOKUP Function (3)

This is illustrated in the abovespreadsheet on the right. The function finds the name 'Ed'in the top row of the table_array and then returns the value'61%' from the 5th row of the table_array.

If we change the name in cell A10 of the spreadsheet from 'Ed' to 'Cara', the Hlookupfunction would automatically recalculate the function to display the exam result for Cara.

Note that although the top row of the table_arrayis in ascending order in this example, this is not essential, because the[range_lookup] argument is set to FALSE (requiringan exact match).


Hlookup Example 2 - Closest Match Lookup

Cells A1-F3 of the following spreadsheet show body types relating to body mass index (BMI), for theranges 0-18.4, 18.5-24.9, 25.0-29.9 and over 30.

Cell C6 shows the user's current BMI, which is 23.5, and cell C7 shows the Hlookup functionthat is used to look up the body type that relates to this BMI.

The Excel HLOOKUP Function (4)


The Hlookup function in the above spreadsheet returns the result "Normal Weight", which is the correctbody type for a BMI of 23.5.

Note that, in this example, the [range_lookup] argument is set to TRUE,to tell that function that, if it cannot find an exact match to the suppliedlookup_value, it should use the closest match below this value.Therefore,

  • For all BMIs up to and including 18.4 the function would return "Underweight";
  • For all BMIs between 18.5 and 24.9, the function would return "Normal Weight";
  • Etc.

Note also that, in this case, as the [range_lookup] argument is setto TRUE, the top row of the table_array (i.e. cells A2-E2) mustbe in ascending order.


Further Hlookup Examples

For a practical example of the Hlookup function being used to create a variable drop-down list, see theVariable Drop-Down List page.

Also, for further information on the Hlookup function, see theMicrosoft Office website.


Excel Hlookup Function Errors

If you get an error from the Excel Hlookup function this is likely to be one of the following:

Common Errors

#N/A-

Occurs if the Hlookup function fails to find a match to the supplied lookup_value

The cause of this will generally depend on the value of the supplied [range_lookup]:
if [range_lookup] = TRUE
(or is omitted)
-the #N/A error is likely to be because the smallest value in the lookup row is greater than the suppliedlookup_value.
if [range_lookup] = FALSE-

the #N/A error is likely to be because an exact match to the lookup_valueis not found in the lookup row.

If you believe an exact match should have been found by the Hlookup function, see theFailure to Match Values pagefor details on how to diagnose and resolve this problem.
#REF!-Occurs if the supplied row_index_num argument is greater than the numberof rows in the supplied table_array.
#VALUE!-

Occurs if either:

  • The supplied row_index_num argument is < 1 or is non-numeric
or
  • The supplied [range_lookup] argument isnot recognised as TRUE or FALSE.


Return to the List of All Built-In Excel Functions

The Excel HLOOKUP Function (2024)
Top Articles
Latest Posts
Article information

Author: Terence Hammes MD

Last Updated:

Views: 6703

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Terence Hammes MD

Birthday: 1992-04-11

Address: Suite 408 9446 Mercy Mews, West Roxie, CT 04904

Phone: +50312511349175

Job: Product Consulting Liaison

Hobby: Jogging, Motor sports, Nordic skating, Jigsaw puzzles, Bird watching, Nordic skating, Sculpting

Introduction: My name is Terence Hammes MD, I am a inexpensive, energetic, jolly, faithful, cheerful, proud, rich person who loves writing and wants to share my knowledge and understanding with you.