+ Reply to Thread
Results 1 to 11 of 11

HLOOKUP using MATCH and INDEX

  1. #1
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    HLOOKUP using MATCH and INDEX

    Hello everyone,

    I have a row (#2) which contains dates, month by month over 5 years, and another row which contains sales forcasts. I would like to know how I can retrieve the month for which the sales forecasts start (i.e. the first month where forecast is not 0).

    I have tried doing so with the following formula:

    =INDEX("Dates Row",(MATCH(1,"Forecasts Row",-1))). However, I think my problem is that in order to use the -1 indicator, the data needs to be sorted (in ascending or descending order, idk). I obviously can't do that, otherwise it would mess up my table.

    Any tips, help, solutions?

    Thanks a lot,

    Coco

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: HLOOKUP using MATCH and INDEX

    Try this array formula entered with CTRL + SHIFT + ENTER

    =INDEX(A1:M1,MIN(IF(A2:M2<>0,COLUMN(A2:M2))))

    A1:M1 are the dates A2:M2 are the Sales forcasts.

  3. #3
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: HLOOKUP using MATCH and INDEX

    Thank you so much Jonmo, but when I try to do it I get a #REF error. Any idea why?

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: HLOOKUP using MATCH and INDEX

    Can you post the formula you used that produces that error?
    It's likely the column references don't match in each part of the formula.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: HLOOKUP using MATCH and INDEX

    Maybe this...

    Array entered**:

    =INDEX(A1:Z1,MATCH(TRUE,A2:Z2>0,0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Adjust the ranges to suit.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: HLOOKUP using MATCH and INDEX

    =INDEX('[New-International Forecasts.xlsm]Conso'!$CN$2:$FG$2,MIN(IF(INDIRECT("'[" & 'External Data'!$I$2 & "]" & 'External Data'!$I$3 & "'!" & "CN"&Y3):INDIRECT("'[" & 'External Data'!$I$2 & "]" & 'External Data'!$I$3 & "'!" & "FG"&Y3)<>0,COLUMN(INDIRECT("'[" & 'External Data'!$I$2 & "]" & 'External Data'!$I$3 & "'!" & "CN"&Y3):INDIRECT("'[" & 'External Data'!$I$2 & "]" & 'External Data'!$I$3 & "'!" & "FG"&Y3)))))


    This is what I am trying to use. Sorry for the long INDIRECT formulas, but it's the best way I found to use an index number as a row number haha

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: HLOOKUP using MATCH and INDEX

    My advice...
    Get it working with standard hard coded ranges first...
    THEN, work on making it dynamic..


    Also, Tony's formula is probably better..Assuming your values will NOT be negative.
    Last edited by Jonmo1; 05-22-2013 at 09:37 AM.

  8. #8
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: HLOOKUP using MATCH and INDEX

    Side note: for the products for which I have no forecast, it returns the first date in the file (41395, or May 1st 2013)

  9. #9
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: HLOOKUP using MATCH and INDEX

    Actually, Tony's advice worked!

    Thank you both for your help and time, it's much appreciated!

    If I figure out that #REF error I'll post why

    Have a good one,

    coco

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: HLOOKUP using MATCH and INDEX

    Quote Originally Posted by cocostar88 View Post
    Side note: for the products for which I have no forecast, it returns the first date in the file (41395, or May 1st 2013)
    for that you can probably just take the final working formula, and wrap it in an Iferror
    =IFERROR(..workingformula..,$CN$2)

    CN2 = the first date in the range.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: HLOOKUP using MATCH and INDEX

    Good deal. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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