+ Reply to Thread
Results 1 to 15 of 15

Problem: HLOOKUP function as an array formula not working!

  1. #1
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Problem: HLOOKUP function as an array formula not working!

    Hi there,

    I'm simplifying my problem here down to the bare minimum so as not to confuse I hope!

    (My actual data is over several excel sheets with thousands of row and columns of data)

    If I set my data up like this:

    A B C D E F G H
    1 John Mark Luke Dan John Mark Luke Dan
    2 10 20 30 40
    3 50 60 70 80

    My goal is to replicate Cells A2:D3 into E2:H3 using HLOOKUP as an array formula.

    Obviously I can do this if I enter the following non-array formula into each of cells E2:H3
    =HLOOKUP($E1,$A$1:$D$3,ROW(),FALSE)

    My question is how do I replicate this result using a single HLOOKUP array formula across cells E2:H3?

    Currently I'm doing this single array formula across cells F2:I3:
    ={HLOOKUP(E1:H1,A1:D3,ROW(),FALSE)}

    And i get the following result on the right and table:

    A B C D E F G H
    1 John Mark Luke Dan John Mark Luke Dan
    2 10 20 30 40 10 20 30 40
    3 50 60 70 80 10 20 30 40

    As you can see, the second line (cells E3:H3) are not calculating as I'm hoping.

    I'm sure I'm doing something obvious but just can't see it.

    Any help would be greatly appreciated!

    Cheers,
    Tom

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Problem: HLOOKUP function as an array formula not working!

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem: HLOOKUP function as an array formula not working!

    Sure - here you go, with a couple of annotations...

    Many thanks
    Attached Files Attached Files

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Problem: HLOOKUP function as an array formula not working!

    In G11 Cell - Normal Formula

    =IFERROR(HLOOKUP(G$10,$A$3:$D$5,ROW(2:2),FALSE),"")

    Drag it down and right...

  5. #5
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem: HLOOKUP function as an array formula not working!

    Hi sixth sense,

    Thanks but my initial question stated that the formula has to be a single ARRAY formula (i.e. using CTRL+SHIFT+ENTER) that works across all the cells, not just an HLOOKUP that insert into each cell.

    I know plenty of ways to do it with individual non-array formulas in each cell - for example your one.

    Do you know how to do it as an array? If you look at my example, you'll see that it isn't working for me - so i must be doing something wrong.

    Many thanks,
    Tom

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Problem: HLOOKUP function as an array formula not working!

    Thanks but my initial question stated that the formula has to be a single ARRAY formula
    why? If a regular formula is working for you, why not stick with it?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Problem: HLOOKUP function as an array formula not working!

    if you must have an array formula which when processing large data sets might not be the most efficient way of doing things something simple like this will work if you know the range of cells of the original data.\

    Using your example, select an area the same dimension as the original data A3:D5 enter this in the formula bar =A3:D5 and enter with Ctrl + Shift + Enter
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  8. #8
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem: HLOOKUP function as an array formula not working!

    Thanks all for looking:

    FDibbins - sure, good question - three reasons mainly 1) My computer is not the best and given that my original data set is so huge, it seems to be coping a lot more easily with Array formulas that cover large amounts of cells rather than hundreds of thousands of individual formulas. 2) It's far neater for me and given that I want everything automated on my original data set, before I hand it over to someone else, I want there to be fewer ways in which the formulas could be messed up by a third party - arrays have the advantage scaring of most laymen away! 3) I'm now genuinely curious - is it actually possible to use HLOOKUP as an Array formula?

    newdoverman - curious to hear about any more efficient ways of processing large amounts of data if an array formula isn't the best way here. The formula you've given unfortunately won't work for my purposes because it doesn't replicate the HLOOKUP functionality. In your example, all that would achieve is to copy the data, whereas I will be wanting to actually pull data out of the original data, skipping columns that I don't want. So it has to be something that works like an HLOOKUP

    Hope that clarifies.
    Cheers,
    Tom

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Problem: HLOOKUP function as an array formula not working!

    Take a look at the series on Youtube by Excelisfun. He has a series on the efficiency of formulae and he also discusses the use of array formulae vs standard formulae for large data sets....He has well over a 1000 videos so you will have to do some searching.

  10. #10
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem: HLOOKUP function as an array formula not working!

    Cheers for that, will take a look through - very useful with my aging computer!

    Don't suppose you've any other thoughts on the HLOOKUP as an Array? I'm starting to think that HLOOKUP just doesn't work when you use it as an array? It simply doesn't seem to be picking out the anything past the first line of data...

  11. #11
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem: HLOOKUP function as an array formula not working!

    BTW - I can make the HLOOKUP array formula work across any single row or down any single column, I just can't use the same HLOOKUP array formula across multiple rows and columns - very frustrating and makes me think that I'm missing something simple...

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Problem: HLOOKUP function as an array formula not working!

    Select E1:H3 and Array Enter:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    using Ctrl-Shift-Enter rather than just Enter

    Admittedly, not HLOOKUP. But it is the same Array Entered formula in all 12 cells. It cannot be extended down or across, and you cannot delete or edit any of the cells.

    See the attached example workbook.

    Regards, TMS
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  13. #13
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Problem: HLOOKUP function as an array formula not working!

    Here is an extract from http://msdn.microsoft.com/en-us/library/ff726673(v=office.14).aspx#xlArraySumProduct that you may want to consider before committing to Array formula solution to your problem: The pertinent bit is:
    "Array Formulas and SUMPRODUCT

    "Array formulas and the SUMPRODUCT function are powerful, but you must handle them carefully. A single array formula might require a large number of calculations.

    The key to optimizing the calculation speed of array formulas is to ensure that the number of cells and expressions that are evaluated in the array formula is as small as possible. Remember that an array formula is a bit like a volatile formula: If any one of the cells that it references has changed, is volatile, or has been recalculated, the array formula calculates all the cells in the formula and evaluates all the virtual cells it needs to do the calculation.
    To optimize the calculation speed of array formulas:

    •Take expressions and range references out of the array formulas into separate helper columns and rows. This makes much better use of the smart recalculation process in Excel.
    •Do not reference complete rows, or more rows and columns than you need. Array formulas are forced to calculate all the cell references in the formula even if the cells are empty or unused. With 1 million rows available starting in Excel 2007, an array formula that references a whole column is extremely slow to calculate.
    •Starting in Excel 2007, use structured references where you can to keep the number of cells that are evaluated by the array formula to a minimum.
    •In versions before Excel 2007, use dynamic range names where possible. Although they are volatile, it is worthwhile because they minimize the size of the ranges.
    •Be careful with array formulas that reference both a row and a column: this forces the calculation of a rectangular range.
    •Use SUMPRODUCT if possible; it is slightly faster than the equivalent array formula."

    Quote from www.ozgrid.com

    "Perhaps the biggest problem with array formulae is that they look efficient, but when compared to an alternative, nothing could be further from the truth! An array formulae must follow rules that Excels built in Functions do not have to, that is they must loop through each and every cell they reference (one at a time) and check them off against a criteria. For this reason arrays are best suited to being used on single cells or referencing only small ranges."

    Here is another simple non array formula that will do what you describe as your problem. Place in the cell where you want the data to star and copy across and down or down and across....doesn't matter

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by newdoverman; 03-02-2014 at 11:19 AM.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Problem: HLOOKUP function as an array formula not working!

    Is this solved? Seems like a while since the OP joined in

  15. #15
    Registered User
    Join Date
    02-28-2014
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem: HLOOKUP function as an array formula not working!

    Thanks everyone for all the tries and effort put in, very much appreciated. Apologies for the delay as have been away.

    TMS, to answer your question - no, it isn't solved unfortunately. My growing suspicion is that HLOOKUPs simply do not actually work as arrays - a suspicion that is supported by the fact that no one has attempted to tackle the problem directly from that point of view (i.e. trying to use HLOOKUPs)

    Your response using the INDEX function, as you mentioned, regrettably doesn't tackle/solve the issue of being able to change the columns around/ skip columns etc that you could do if you used an HLOOKUP. Aside from that, a simpler way of doing the same as what you've done is to simply use the array {=A3:D5}, which would recreate the cells using a single array formula but wouldn't require the use of the INDEX function (which would slow processing on a large data set).

    So I'm still very interested if anyone can come up with a novel way of tackling/ solving my original post, but I'm not holding my breath as I think it may not be possible!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Problem with Indirect function in HLOOKUP
    By lilaustino in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-25-2012, 05:03 AM
  2. Average & Min Function Problem in Array Formula
    By mubashir aziz in forum Excel General
    Replies: 8
    Last Post: 05-20-2009, 02:07 AM
  3. Table Array within hlookup not working
    By mattted in forum Excel General
    Replies: 3
    Last Post: 03-03-2009, 07:09 PM
  4. Replies: 7
    Last Post: 07-05-2006, 12:10 PM
  5. [SOLVED] HLookup? or an array function??
    By Murph in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-11-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1