+ Reply to Thread
Results 1 to 5 of 5

Max reverse lookup

Hybrid View

  1. #1
    Registered User
    Join Date
    01-30-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Max reverse lookup

    Hi,
    I am stuck at trying to get the rows of Max value (in a given column) from a table and return the values in a corresponding column. The trick is I need multiple Max values (and their product descriptions) based on the different vendor row in the table... maybe easier if you look at attached sample.

    Thank you in advance fo your help!

    Marc
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Max reverse lookup

    Put this array formula in H5 and confirm it with CTRL-SHIFT-ENTER to activate the array:

    =MAX(IF($B$4:$B$15=$F5, $D$4:$D$15, ""))

    Copy that down.

    Then put this regular formula in G5 and copy down:

    =INDEX($C$4:$C$15, MATCH(F5&"-"&H5, INDEX($B$4:$B$15&"-"&$D$4:$D$15, 0), 0))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-30-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Max reverse lookup

    Quote Originally Posted by JBeaucaire View Post
    Put this array formula in H5 and confirm it with CTRL-SHIFT-ENTER to activate the array:

    =MAX(IF($B$4:$B$15=$F5, $D$4:$D$15, ""))

    Copy that down.

    Then put this regular formula in G5 and copy down:

    =INDEX($C$4:$C$15, MATCH(F5&"-"&H5, INDEX($B$4:$B$15&"-"&$D$4:$D$15, 0), 0))
    JBeaucaire,
    Thanks Beaucaire!!! I was hoping to avid the array function... as I will be dropping these furmulas into cells using a macro (Sheets(shtMain).Range("Prod_Mkt").FormulaR1C1 =) as the raw data varies based on monthly publish (number of rows will vary).

    How can I enter this array formula via a macro? Maybe that is the answer...

    Thank you for the help!!

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Max reverse lookup

    This is the wrong forum if you know in advance you want a programming answer, you should pose those questions in the Programming forum.

    Anyway:
        Range("G5:G8").FormulaR1C1 = _
            "=INDEX(R4C3:R15C3, MATCH(RC[-1]&""-""&RC[1], INDEX(R4C2:R15C2&""-""&R4C4:R15C4, 0), 0))"
    
        With Range("H5")
            .FormulaArray = "=MAX(IF(R4C2:R15C2=RC6,R4C[-4]:R15C[-4],""""))"
            .AutoFill Destination:=Range("H5:H8")
        End With
    You can get code like this by just turning on the macro recorder to record you entering the formulas in one cell, then edit out the "selecting".

  5. #5
    Registered User
    Join Date
    01-30-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Max reverse lookup

    JBeaucaire,
    With your suggestion I can avoid the macro placing the formula and I can actually lock it down in a hidden table... only when I placed sample up I made a slight error. There are multiple entries for the same product / vendor code based on sales Qtr. How can I sum these up and find the MAX based on total sales during the period?

    I updated the sample.

    Many thanks!!!!!!!!!!
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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