+ Reply to Thread
Results 1 to 10 of 10

Can vlookup return highest cell value of in the relation to Lookup Value?

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Can vlookup return highest cell value of in the relation to Lookup Value?

    I have a spreadsheet of data that includes the following:


    S# Record # SO # Line # SIZE DATE
    11A035 1 5703 1 12M 03/02/13
    11A035 1 6177 1 12M 04/20/13
    11A036 2 5804 1 12M 03/18/13
    11A036 2 6295 1 NB 05/20/13
    11A040 6 5804 35 12M 03/18/13
    11A040 6 6295 6 NB 05/20/13
    09A288 522 7037 7 18M 04/29/13
    58A471 1143 5929 93 5T 03/29/13
    58A471 1143 7167 20 2T 04/26/13

    What I am trying to accomplish is to return the SO# with the earliest date based on the S#. I am trying to write a VLookup function that has the S# as the Lookup value and returns the SO# of the earliest date record.

    For instance, my formula should return 5703 for S#11A035 and 5929 for S# 58A471.

    I tried using a VLookup + MIN function but that didn't work out for me. Should I use a Pivot table? Any help would be greatly appreciated.

  2. #2
    Valued Forum Contributor Melvinrobb's Avatar
    Join Date
    06-19-2012
    Location
    Manitoba, Canada
    MS-Off Ver
    Excel 2013
    Posts
    1,128

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    I added a helper column which adds a ranking based on the date.
    The vlookup can then work.
    Please click the * icon below if I have helped.

  3. #3
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,843

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    ----------------
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  4. #4
    Registered User
    Join Date
    03-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    Quote Originally Posted by Melvinrobb View Post
    I added a helper column which adds a ranking based on the date.
    The vlookup can then work.
    Thank you for your help but this spreadsheet has 26740 rows, I don't know if I could efficiently rank all the various dates. This was just a very small subset. I will try more though.

    Any one else? Thanks

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

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    with that info in a1:f10 this array formula should do it
    =INDEX($C$2:$C$10,MATCH(H2&MIN(IF($A$2:$A$10=H2,$F$2:$F$10)),INDEX($A$2:$A$10&$F$2:$F$10,0),0))
    or you could split that over 2 cells see attached
    Attached Files Attached Files
    "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

  6. #6
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,843

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    I think this does what you want. It's an array formula and has to be entered with Ctrl+Shift+Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    Quote Originally Posted by martindwilson View Post
    with that info in a1:f10 this array formula should do it
    =INDEX($C$2:$C$10,MATCH(H2&MIN(IF($A$2:$A$10=H2,$F$2:$F$10)),INDEX($A$2:$A$10&$F$2:$F$10,0),0))
    or you could split that over 2 cells see attached
    The split into 2 cells looks to be working. Let me work with it more. Thanks guys.

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

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    Are the dates always in ascending order (relative to each S#) ?
    So the earliest date is always the first date for each S# ?
    It appears so in your sample dataset

    In this case, a plain old exact match VLOOKUP will work

    =VLOOKUP(S#,A:C,3,0)

  9. #9
    Registered User
    Join Date
    03-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    Quote Originally Posted by Jonmo1 View Post
    Are the dates always in ascending order (relative to each S#) ?
    So the earliest date is always the first date for each S# ?
    It appears so in your sample dataset

    In this case, a plain old exact match VLOOKUP will work

    =VLOOKUP(S#,A:C,3,0)
    No, the earliest date is not always the first.

  10. #10
    Registered User
    Join Date
    03-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Can vlookup return highest cell value of in the relation to Lookup Value?

    Quote Originally Posted by martindwilson View Post
    with that info in a1:f10 this array formula should do it
    =INDEX($C$2:$C$10,MATCH(H2&MIN(IF($A$2:$A$10=H2,$F$2:$F$10)),INDEX($A$2:$A$10&$F$2:$F$10,0),0))
    or you could split that over 2 cells see attached
    YEP! the split works! Thanks guys.

+ 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