+ Reply to Thread
Results 1 to 9 of 9

Vlookup with multiple criteria & ranking

  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Vlookup with multiple criteria & ranking

    I need help! Basically I need to create a array formula in Microsoft Excel (not allowed to use a macro) to do multiple functions. I have a list of data that can be updated regularly and can not be sorted. So additional line items can be added at any time (I have specified the max of data) I have created dummy data below. I want to find all the “Apple” Entries and then look up the highest B Value and Display Column C. And then I want to look up the next “Apple” with the 2nd highest B Value and Display Column C again.

    Data Sheet
    A B C
    Apple 5 300
    Banana 20 125
    Cherry 25 200
    Apple 10 210
    Cherry 25 250
    Apple 15 100

    OUTPUT
    Apple (Column C Data) (Highest B Value) == Apple 100 15
    Apple (Column C Data) (2nd highest B Value) == Apple 210 15

    (do not display next Apple Data)

    I was using the following formula, but it does not select the largest value Column B first.
    =IF(ISERROR(INDEX($A$2:$C$6,SMALL(IF(A$2:$C$6="Apple",ROW(A$2:$C$6)-ROW(A$2)+1,ROW(C$6,)+1),1),2)),"NONE",(INDEX(($A$2:$C$6,SMALL(IF(A$2:$C$6="Apple",ROW(A$2:$C$6)-ROW(A$2)+1,ROW(C$6,)+1),1),2)))

    I also tried this formula, but the large function does not seem function correctly when there are duplicate values or when the value is blank. APPLE=Row A, BValues=Row B, and All Values = Row B & C.

    =IF(ISNUMBER(MATCH("Apple",FRUIT,0)),VLOOKUP(LARGE((FRUIT="Apple")*(BVALUES),1),ALLVALUES,2,0),"")

    Any ideas? I know this is complicated so feel free to ask questions I will do my best to explain.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Vlookup with multiple criteria & ranking

    Hi,

    Attached is a step-by-step test for you ...

    HTH
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-12-2009
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Vlookup with multiple criteria & ranking

    This looks like it works, unfortunately I don't have the luxury to have data in multiple cells. So basically I need to come to the solution with 1 formula instead of two. Is there a way to nest these two formulas together? Any other ideas?

  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: Vlookup with multiple criteria & ranking

    Try this, one cell formulas...
    Attached Files Attached Files
    _________________
    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!)

  5. #5
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Vlookup with multiple criteria & ranking

    My two cents added. The formula consists of two concatenated parts, to give both results in one cell, as requested i think.
    To complicate matters, i tweaked the given data slightly to force a triple ex-aequo on "Apples". In these circumstances, the formula returns the first occurring (in ascending row order) results.
    Attached Files Attached Files
    Last edited by WHER; 11-13-2009 at 12:34 PM.

  6. #6
    Registered User
    Join Date
    11-12-2009
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Vlookup with multiple criteria & ranking

    Wher---we are soo close!

    It looks like this does everything correctly. The only issue I still need to determine how to handle is how to correctly account for when there is a Row for Apple with no data or "0" data in column B. With your current function it looks like it just grabs the next row of data (regardless if it is an "apple" or not).

    I appreciate all the help. Keep the ideas coming =)

  7. #7
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Vlookup with multiple criteria & ranking

    Getting closer?
    Attached Files Attached Files

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup with multiple criteria & ranking

    I don't have the luxury to have data in multiple cells
    . what's that mean?
    you can always hide columns or do the calculations on another sheet and refer to it then hide sheet
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    11-12-2009
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Vlookup with multiple criteria & ranking

    WHER--Great work! You got it!! Thanks so much. Sorry my reply is so late, I had to finalize some other projects before I could finish this one.

    Martindwilson- I basically needed 1 formula to get my answer, one of the previous examples had 1 cell with 1 response and the 2nd sell referenced the 1st. I actually didn't need the data in the same cell, so with WHER's solution I just split out the data into seperate cells. (Hard to explain!).

    I really appreciate all the help/time/effort for everyone. Have a great weekend!

+ 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