This Excel tutorial explains how to use the Excel **HLOOKUP function** with syntax and examples.

The Microsoft Excel **HLOOKUP function** performs a horizontal lookup by searching for a value in the top row of the *table* and returning the value in the same column based on the *index_number*.

The syntax for the Microsoft Excel **HLOOKUP function** is:

HLOOKUP( value, table, index_number, [not_exact_match] )

*value* is the value to search for in the first row of the *table*.

*table* is two or more rows of data that is sorted in ascending order.

*index_number* is the row number in *table* from which the matching value must be returned. The first row is 1.

*not_exact_match* is optional. It determines if you are looking for an exact match based on *value*. Enter FALSE to find an exact match. Enter TRUE to find an approximate match, which means that if an exact match if not found, then the **HLOOKUP function** will look for the next largest value that is less than *value*. If this parameter is omitted, **HLOOKUP** will return an approximate match.

- If
*index_number*is less than 1, the**HLOOKUP function**will return #VALUE!. - If
*index_number*is greater than the number of columns in*table*, the**HLOOKUP function**will return #REF!. - If you enter FALSE for the
*not_exact_match*parameter and no exact match is found, then the**HLOOKUP function**will return #N/A. - See also the VLOOKUP function to perform a vertical lookup.

The **HLOOKUP function** can be used in the following versions of Microsoft Excel:

- Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

The **HLOOKUP function** can be used in Microsoft Excel as the following type of function:

- Worksheet function (WS)

Let's look at some Excel HLOOKUP function examples and explore how to use the **HLOOKUP function** as a worksheet function in Microsoft Excel:

Based on the spreadsheet above, the following Excel **HLOOKUP function** will return the following:

=HLOOKUP(10251, A1:G3, 2, FALSE)Result:$16.80

This HLOOKUP example would return the value of $16.80. Let's take a closer look why.

The first parameter in the HLOOKUP function is the *value* to search for. So in this example, the HLOOKUP is searching for the value of 10251.

The second parameter in the HLOOKUP function is the *table* which is set to the range of A1:G3. The HLOOKUP uses the first row in this range (ie: A1:G1) to search for the value of 10251.

The third parameter is the *index_number* which is set to 2. This means that the second row in the *table* is where we will find the value to return. Since the *table* is set to A1:G3, the corresponding return value will be in A2:G2 (ie: second row as specified by the index_number of 2).

**Finally and most importantly** is the fourth or last parameter in the HLOOKUP. In our example, it is set to FALSE. This means that you need to find an EXACT match for the value of 10251. We do not want to find a "close" match, but an EXACT match!! So if 10251 is not found in the range of A1:G1, then the HLOOKUP function should return #N/A.

Since the HLOOKUP is able to find the value of 10251 in the range A1:G1, it returns the corresponding value from A2:G2 which is $16.80.

**Importance of final parameter!!!!!!**

Let's further explore the importance of specifying TRUE vs FALSE for the last parameter in the HLOOKUP function.

So say we are looking for the Order ID of 10248, but as you can see, it is not in the range of A1:G1 in the spreadsheet above. Let's write our HLOOKUP formula with FALSE as the final parameter and another HLOOKUP formula with TRUE as the final parameter and see what happens.

=HLOOKUP(10248, A1:G3, 2, FALSE)Result:#N/A =HLOOKUP(10248, A1:G3, 2, TRUE)Result:$14.00

The first HLOOKUP formula has FALSE specified as the final parameter. This means that the HLOOKUP is looking for an exact match for 10248. Since the value 10248 does not exist in the range A1:G1, the HLOOKUP function returns #N/A.

The second HLOOKUP formula has TRUE specified as the final parameter. This means that if an exact match if not found, the HLOOKUP function will look for the next largest value that is less than 10248. Now what does this mean to us?

First of all, it means that the data in A1:G3 **MUST BE SORTED IN ASCENDING ORDER** because the HLOOKUP is going to return the next largest value for 10248 and then stop searching. So if your data is not sorted in ascending order, you are going to get some really strange results.

Secondly, it means that the HLOOKUP function will find order 10247 as the approximate match. And therefore, return $14.00 as the result (the corresponding value from A2:G2).

Quite often we are asked the question, "What is an example of a HLOOKUP when the table is on another sheet?"

To answer that question, let's modify our example above and assume that the table is on Sheet2 in the range A1:G3.

We could rewrite our example as follows:

=HLOOKUP(10251, Sheet2!A1:G3, 2, FALSE)

By preceding the table range with the sheet name and an exclamation mark, we can update our HLOOKUP to reference a table on another sheet.

Let's throw in one more complication, what happens if your Sheet name contains spaces, then you will need to change the formula further. So let's take a look at this case...

Let's assume that the table is on a Sheet called "Test Sheet" in the range A1:G3, we would need to modify our formula as follows:

=HLOOKUP(10251, 'Test Sheet'!A1:G3, 2, FALSE)

By placing the sheet name within single quotes, we can accommodate a sheet name with spaces in our HLOOKUP function.

Now it is important for us to mention one more mistake that is commonly made. When people use the HLOOKUP function, they commonly use relative referencing for the table range like we did in our examples above. This will return the right answer, but what happens when you copy the formula to another cell? The table range will be adjusted by Excel and change relative to where you paste the new formula. Let's explain further...

So if you had the following formula in cell J1:

=HLOOKUP(10251, A1:G3, 2, FALSE)

And then you copied this formula from cell J1 to cell K2, it would modify the HLOOKUP formula to this:

=HLOOKUP(10251, B2:H4, 2, FALSE)

Since your table is found in the range A1:G3 and not B2:H4, your formula would return erroneous results in cell K2. To ensure that your range is not changed, try referencing your table range using absolute referencing as follows:

=HLOOKUP(10251, $A$1:$G$3, 2, FALSE)

Now if you copy this formula to another cell, your table range will remain $A$1:$G$3.

(scroll to see more)

- ABS (WS, VBA)
- ACCRINT (WS)
- ACCRINTM (WS)
- ACOS (WS)
- ACOSH (WS)
- ADDRESS (WS)
- AGGREGATE (WS)
- AMORDEGRC (WS)
- AMORLINC (WS)
- AND (WS)
- AND (VBA)
- AREAS (WS)
- ASC (VBA)
- ASIN (WS)
- ASINH (WS)
- ATAN (WS)
- ATAN2 (WS)
- ATANH (WS)
- ATN (VBA)
- AVEDEV (WS)
- AVERAGE (WS)
- AVERAGEA (WS)
- AVERAGEIF (WS)
- AVERAGEIFS (WS)
- BETA.DIST (WS)
- BETA.INV (WS)
- BETADIST (WS)
- BETAINV (WS)
- BIN2DEC (WS)
- BIN2HEX (WS)
- BIN2OCT (WS)
- BINOM.DIST (WS)
- BINOM.INV (WS)
- BINOMDIST (WS)
- CASE (VBA)
- CBOOL (VBA)
- CBYTE (VBA)
- CCUR (VBA)
- CDATE (VBA)
- CDBL (VBA)
- CDEC (VBA)
- CEILING (WS)
- CEILING.PRECISE (WS)
- CELL (WS)
- CHAR (WS)
- CHDIR (VBA)
- CHDRIVE (VBA)
- CHIDIST (WS)
- CHIINV (WS)
- CHITEST (WS)
- CHOOSE (WS, VBA)
- CHR (VBA)
- CINT (VBA)
- CLEAN (WS)
- CLNG (VBA)
- CODE (WS)
- COLUMN (WS)
- COLUMNS (WS)
- COMBIN (WS)
- COMBINA (WS)
- COMPLEX (WS)
- Concat with & (WS, VBA)
- CONCATENATE (WS)
- CONVERT (WS)
- COS (WS, VBA)
- COSH (WS)
- COUNT (WS)
- COUNTA (WS)
- COUNTBLANK (WS)
- COUNTIF (WS)
- COUNTIFS (WS)
- COVAR (WS)
- CSNG (VBA)
- CSTR (VBA)
- CURDIR (VBA)
- CVAR (VBA)
- DATE (VBA)
- DATE (WS)
- DATEADD (VBA)
- DATEDIF (WS)
- DATEDIFF (VBA)
- DATEPART (VBA)
- DATESERIAL (VBA)
- DATEVALUE (WS, VBA)
- DAVERAGE (WS)
- DAY (WS, VBA)
- DAYS360 (WS)
- DB (WS)
- DCOUNT (WS)
- DCOUNTA (WS)
- DDB (WS, VBA)
- DEGREES (WS)
- DGET (WS)
- DIR (VBA)
- DMAX (WS)
- DMIN (WS)
- DOLLAR (WS)
- DPRODUCT (WS)
- DSTDEV (WS)
- DSTDEVP (WS)
- DSUM (WS)
- DVAR (WS)
- DVARP (WS)
- ERROR.TYPE (WS)
- EVEN (WS)
- EXACT (WS)
- EXP (WS, VBA)
- FACT (WS)
- FALSE (WS)
- FILEDATETIME (VBA)
- FILELEN (VBA)
- FIND (WS)
- FIX (VBA)
- FIXED (WS)
- FLOOR (WS)
- FORECAST (WS)
- FORMAT Dates (VBA)
- FORMAT Numbers (VBA)
- FORMAT Strings (VBA)
- FREQUENCY (WS)
- FV (WS, VBA)
- GETATTR (VBA)
- GROWTH (WS)
- HLOOKUP (WS)
- HOUR (WS, VBA)
- HYPERLINK (WS)
- IF (WS)
- IF-THEN-ELSE (VBA)
- IFs (more than 7) (WS)
- IFs (up to 7) (WS)
- INDEX (WS)
- INDIRECT (WS)
- INFO (WS)
- INSTR (VBA)
- INSTRREV (VBA)
- INT (WS, VBA)
- INTERCEPT (WS)
- IPMT (WS, VBA)
- IRR (WS, VBA)
- ISBLANK (WS)
- ISDATE (VBA)
- ISERR (WS)
- ISERROR (WS, VBA)
- ISLOGICAL (WS)
- ISNA (WS)
- ISNONTEXT (WS)
- ISNULL (VBA)
- ISNUMBER (WS)
- ISNUMERIC (VBA)
- ISPMT (WS)
- ISREF (WS)
- ISTEXT (WS)
- LARGE (WS)
- LCASE (VBA)
- LEFT (WS, VBA)
- LEN (WS, VBA)
- LINEST (WS)
- LN (WS)
- LOG (WS, VBA)
- LOG10 (WS)
- LOOKUP (WS)
- LOWER (WS)
- LTRIM (VBA)
- MATCH (WS)
- MAX (WS)
- MAXA (WS)
- MDETERM (WS)
- MEDIAN (WS)
- MID (WS, VBA)
- MIN (WS)
- MINA (WS)
- MINUTE (WS, VBA)
- MINVERSE (WS)
- MIRR (WS, VBA)
- MKDIR (VBA)
- MMULT (WS)
- MOD (WS)
- MONTH (WS, VBA)
- MONTHNAME (VBA)
- N (WS)
- NA (WS)
- NETWORKDAYS (WS)
- NETWORKDAYS.INTL (WS)
- NOT (WS)
- NOW (WS, VBA)
- NPER (WS, VBA)
- NPV (WS, VBA)
- ODD (WS)
- OFFSET (WS)
- OR (WS)
- OR (VBA)
- PERCENTILE (WS)
- PERCENTRANK (WS)
- PERMUT (WS)
- PI (WS)
- PMT (WS, VBA)
- POWER (WS)
- PPMT (WS, VBA)
- PRODUCT (WS)
- PROPER (WS)
- PV (WS, VBA)
- QUARTILE (WS)
- RADIANS (WS)
- RAND (WS)
- RANDBETWEEN (WS)
- RANK (WS)
- RATE (WS, VBA)
- REPLACE (WS)
- REPLACE (VBA)
- REPT (WS)
- RIGHT (WS, VBA)
- RND (VBA)
- ROMAN (WS)
- ROUND (WS)
- ROUND (VBA)
- ROUNDDOWN (WS)
- ROUNDUP (WS)
- ROW (WS)
- ROWS (WS)
- RTRIM (VBA)
- SEARCH (WS)
- SECOND (WS)
- SETATTR (VBA)
- SGN (VBA)
- SIGN (WS)
- SIN (WS, VBA)
- SINH (WS)
- SLN (WS, VBA)
- SLOPE (WS)
- SMALL (WS)
- SPACE (VBA)
- SQRT (WS)
- STDEV (WS)
- STDEVA (WS)
- STDEVP (WS)
- STDEVPA (WS)
- STR (VBA)
- STRCOMP (VBA)
- STRCONV (VBA)
- SUBSTITUTE (WS)
- SUBTOTAL (WS)
- SUM (WS)
- SUMIF (WS)
- SUMIFS (WS)
- SUMPRODUCT (WS)
- SUMSQ (WS)
- SUMX2MY2 (WS)
- SUMX2PY2 (WS)
- SUMXMY2 (WS)
- SWITCH (VBA)
- SYD (WS, VBA)
- T (WS)
- TAN (WS, VBA)
- TANH (WS)
- TEXT (WS)
- TIME (WS)
- TIMESERIAL (VBA)
- TIMEVALUE (WS, VBA)
- TODAY (WS)
- TRANSPOSE (WS)
- TRIM (WS, VBA)
- TRUE (WS)
- TRUNC (WS)
- TYPE (WS)
- UCASE (VBA)
- UPPER (WS)
- VAL (VBA)
- VALUE (WS)
- VAR (WS)
- VARA (WS)
- VARP (WS)
- VARPA (WS)
- VDB (WS)
- VLOOKUP (WS)
- WEEKDAY (WS, VBA)
- WEEKDAYNAME (VBA)
- YEAR (WS, VBA)
- --- end ---

While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.

Copyright © 2003-2015 TechOnTheNet.com. All rights reserved.