Apr 23 2007

HLookup in Excel

I thought a good next post would to add how to use HLookup after posting the VLookup information last time. The two functions are very similar only they do the opposite things with it comes to looking a against a table.

Let’s start by taking a look at the formula for HLookup:

HLookup(lookup_value, table_array, row_index_num, range_lookup)

lookup_value is what you are searching for in the first column of the table_array

table_array is the range you would like to look up a value for. You must include both the column you are looking for a value in and the column of the value you would like to return

row_index_num is the row number in table_array from which the matching value is returned if a match is found. The first column in your table_array range is 1 (Must be positive integer greater than or equal to 1).

range_lookup tells the formula if you are looking for an exact match based on value. Enter FALSE if you want it to find an exact match. Enter True to find an approximate match, in which Hlookup will look for the next largest value that is less than value (Must be sorted in ascending order for approximate match).

Possible Errors You May Receive
#REF – If the column you are indexing is greater than the number of column in you table_array range, you will receive this Error. Also if there is a problem with you table_array reference itself, this error could result
#N/A – If you were looking for an exact match that hlookup cannot find, it will return #N/A. Also if the approximate match cannot find and approximate match it will return #N/A as well
#Value – If you type in a value for an index that is less than 1, you will get this error.

Examples for Hlookup

HLookup Examples

Example 1: =HLookup(“Shirt”,1:4,3,false) will return “Blue”
Another way to to do example1 is to use a cell reference for value:
=HLookup(B1,1:4,2,false) will return “Blue”

Example 2: =HLookup(“Jacket”,1:4,2,false) will return “#N/A”

Example 3 : =HLookup(“Shirt”,1:4,5,false) will return “#REF”

Example 4: =HLookup(“Hat”,1:4,4,false) will return “4″

HLookup can also reference other sheets or even other workbooks that you need to lookup a value on. All you will need is to include a reference to that worksheet or workbook in your formula. I have found that the easiest way is to highlight the range you want looked up with your mouse while you are typing the formula and Excel will automatically fill in the reference for you.

Use IF Statements and ISNA Function along with HLookup
I will be adding sections to the website on both IF Statements and ISNA to the site, but I personally believe using HLookup and these other functions go hand in hand because I use them together so frequently.

Many times when you are using HLookups for a large range of numbers, your result will come back #N/A but you may not want #N/A in your results. For example, you may want to have the formula return a 0 if the match is not found. To do this, you need to use all these functions together. Below is an example of how this could work for you (using the table from able):

Example 1: =IF(ISNA(HLOOKUP(“Jacket”,1:4,3,false)),”Not Found”,”Found”) will return “Not Found”

Example 2: =IF(ISNA(HLookup(“Shirt”,1:4,3,false)),0,HLookup(“Shirt”,1:4,3,false)) will return “Blue”

Features for Future Posts
One of the features that I will explore in a future post is the ability to lookup not just the first instance that the HLookup and VLookup Function finds but he 2nd or 3rd Etc. I will have to post some other Function How-To pages before I get into that though. Also using the Match() formula can be very useful to dynamically choose which row you want based on the criteria. We will explore Indexes and Array soon. Please use the comment section from my blog post to ask me any questions about this feature or give suggestions.

** Excel Hints provides Excel Tips and Excel Help for All Levels of Experience.

More Excel Tips

Did you find this post helpful? Try signing up for our free daily tips.

Enter your email address: 

          

9 Comments on this post

Trackbacks

  1. kaye said:

    MG MGE REM
    55 HC
    29 0 19.5 0
    43 19.5 69.5 0.5
    30 69.5 74.5 1.0
    18 74.5 79.5 1.5
    55 79.5 84.5 2.0
    49 84.5 88.5 2.5
    54 88.5 92.5 3.0
    55 92.5 96.5 3.5
    54 96.5 100 4.0
    table 1.1

    how could i get the MGE, it is said that to come up with MGE make table 1.1 to be the table array with respect to MG… PLS. submit to me the exact formula for this.

    October 1st, 2007 at 6:52 am
  2. ahhm said:

    can you post mORE EXAMPLE!!!for the hlookup func.

    October 1st, 2007 at 7:28 am
  3. john said:

    Kaye – I’m not exactly sure what you are asking here. If you could provide a little more detail as to your exact problem, I would be glad to help. You can either post here, or use the contact form.

    Ahhm – I would be more than happy to provide some more examples. What are you looking for specifically?

    October 1st, 2007 at 9:52 am
  4. radharani said:

    Plz send me how we should do vlookup & hlookup together send me some example some important formulas of excel short cut keys

    March 6th, 2009 at 4:10 am
  5. Ganga Dhar said:

    Please Display more examples for freshers who want to learn excel functions by your website .

    February 10th, 2010 at 6:20 am
  6. jeanette said:

    Plz send me how we should do vlookup & hlookup together send me some example some important formulas of excel short cut keys

    and also send me how to use vlookup and hlookup. I need the steps as I am the beginner.

    Thanks.

    August 3rd, 2010 at 7:39 pm
  7. tripti kumari said:

    how will we use both match & hlookup function together?

    2) can INDEX function will be used with hlookup function?

    September 11th, 2010 at 5:38 am
  8. Chanchal said:

    pls send me some hlookup example pls

    December 11th, 2010 at 1:56 am
  9. Chanchal said:

    wana know some more example in vlookup and hlookup

    December 11th, 2010 at 1:56 am

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sign Up for Excel Hints

Free updates with Excel Hints, Tips & Tricks

Categories

Archives