Excel glossary

How to use HLOOKUP in Excel

HLOOKUP in Excel stands for ‘Horizontal Lookup’. It is a function that makes Excel search for a certain value in a row (the so called ‘table array’), in order to return a value from a different row in the same column.

Definition HLOOKUP function

A HLOOKUP function in Excel exists of 4 components:

  1. The value you want to look up;
  2. The range in which you want to find the value and the return value;
  3. The number of the row within your defined range, that contains the return value;
  4. 0 or FALSE for an exact match with the value your are looking for; 1 or TRUE for an approximate match.

Syntax: HLOOKUP([value], [range], [row number], [false or true])

HLOOKUP example

In our example we show how many pieces of fruits are sold per day in the first week of May. We want to find out how many oranges were sold each day of the week.

First, select a cell in which you want to publish the sold amount of oranges. We start with ‘Day 1’:

How to initiate the HLOOKUP function in Excel // PerfectXL

In our example we show how many pieces of fruits are sold per day in the first week of May. We want to find out how many oranges were sold each day of the week.

First, select a cell in which you want to publish the sold amount of oranges. We start with ‘Day 1’:

Call the HLOOKUP function in Excel // PerfectXL

Then we select the value (from row 1) we want to look up, in this case it’s ‘Orange’ in cell F1.

We can insert this value as a string: “Orange” (image 1), or as a cell reference: F1 (image 2):

Enter the lookup value in a HLOOKUP function as a string // PerfectXL

Image 1, Value as a String

Enter the lookup value in a HLOOKUP function as a cell reference // PerfectXL

Image 2, Value as a Cell Reference

Next we enter ‘;’ and select the range (or table array) in which we want to find the lookup value and the return value. In this case it is range (B1:H8):

Lookup range in a HLOOKUP function in Excel file // PerfectXL

Then we enter ‘;’ and the number of the row within the defined range in which we want to look for the return value. In this case it is row 2 (for day 1), followed by ‘;’ and ‘0’ or ‘FALSE for an exact match with the lookup value ‘Orange’:

Exact match in HLOOKUP function in Excel file // PerfectXL

When we press enter, we get the amount of oranges sold on day 1:

Result of a HLOOKUP function in Excel // PerfectXL

To look up the value for day 2, we can copy the HLOOKUP formula, and replace row 2 with row 3:

=HLOOKUP(“Orange”;B1:H8;3;0):

Expand HLOOKUP function in an Excel file // PerfectXL

We can repeat this proces for each formula within the formula range B12:H12.

In this example we only have a small list of dates, but imagine you have a long list that publishes several years and you wish to use a certain value in other worksheets! Using HLOOKUP (and VLOOKUP) the user only has to change a certain value in one worksheet and it will automatically be changed in all other relevant places.

But what if you’re not certain about your lookup value? Then you can consider an approximate match (set False to True).

Approximate Match in HLOOKUP

When we enter the word ‘Ornage’ in our HLOOKUP function, because we are not sure about the spelling of the value that we’re looking for. The formula as we designed it gets confused, because it can’t find this value in the table array. It returns the standard Excel error #N/A:

Standard Excel error in a HLOOKUP function // PerfectXL

Let us change the ‘0’ (or ‘False’) component of our HLOOKUP function to ‘1’ or ‘TRUE’:

=HLOOKUP(“Ornage”;B1:H8;2;1)
Now we have asked the function to look for an approximate match with ‘Ornage’. If it can’t find the exact match, it will look for the closest match to the value ‘Ornage’, less than ‘Ornage’, which is ‘Orange’:

Approximate match in HLOOKUP function in Excel // PerfectXL

Would we enter ‘Arange’ in stead of “Orange”, the function returns 21, because then ‘Apple’ is the closest match less than ‘Orange’ (based on the alphabet):

Example of approximate match in HLOOKUP function in Excel // PerfectXL