+ Reply to Thread
Results 1 to 13 of 13

VLOOKUP returning values with the most recent date

  1. #1
    Registered User
    Join Date
    11-19-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    VLOOKUP returning values with the most recent date

    Hi Everyone,

    I'm new to this forum and I apologize if this a silly question that has already been answered quite a few times. My basic VLOOKUP formula returns the first instance of the value it can find, however in those cases when there is more than one value available, i'd like to use the one with the most recent date. Please see the example attached.

    I can certainly just sort my entries from latest to oldest date and then run VLOOKUP, but i'd like to see whether it is possible to get this done without sorting.

    Many thanks!!!
    Attached Files Attached Files

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VLOOKUP returning values with the most recent date

    In B3 and copy down.

    =INDEX($G$3:$G$13,SMALL($H$3:$H$13=MAX(IF($F$3:$F$13=A3,$H$3:$H$13),ROW($G$3:$G$13)-2),ROW($A$1)))
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: VLOOKUP returning values with the most recent date

    Perhaps in B3
    Please Login or Register  to view this content.
    and pull down as needed

  4. #4
    Registered User
    Join Date
    11-19-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VLOOKUP returning values with the most recent date

    Thanks so much guys!!! Exactly what i needed.

    Pepe Le Mokko: Just for my own understanding, could you please explain what values 2 and 1 at the beginning of the formula mean. Just want to understand how exactly it works so i can use this formula for other similar use cases.

    Thanks

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: VLOOKUP returning values with the most recent date

    It uses the LOOKUP function in it's vector form.
    The first vector's denominator looks for all values where the date is the largest one given the ID value in range F
    It returns a an array of 0,0,0,1, which after division produces an array like ( DIV/O,DIV/0,1,DIV/0,etc...).
    LOOKUP looks for a 2, which it can't find so chooses the largest value smaller than 2, which is 1 and selects the value of the second vector corresponding to that 1

    Ir's a good idea to use the Evaluate formula tool to see what's going on

  6. #6
    Registered User
    Join Date
    11-19-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VLOOKUP returning values with the most recent date

    Thanks so much for you help!! Have a good day

    Moderators Note: As per Forum Rule #12, don't quote whole posts unless necessary-- it's just clutter...Thanks.
    Last edited by jeffreybrown; 11-28-2012 at 03:46 PM.

  7. #7
    Registered User
    Join Date
    11-19-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VLOOKUP returning values with the most recent date

    Hello,hope you are well. You have helped me the other day in regards to my question on how to vlookup items by the most recent date and on my sample file everything worked perfectly fine. When i'm trying to apply this formula to my real file it doesn't seem to work the same way and I just can't figure out what the issue could be. Could you please take a quick look to see what i'm doing wrong, i'd really appreciate your help.

    I'm attaching a file (i've cut out sensitive fields). I've applied the formula to column B on sheet POS. The value is supposed to be taken from column D on OBS sheet.

    e.g. Sheet POS row 10, pulls 29 for Location id 54. On sheet OBS, 29 is not the value for the most recent date of those available for location id 54.

    Please help.

    Moderators Note: As per Forum Rule #12, don't quote whole posts unless necessary-- it's just clutter...Thanks.
    Attached Files Attached Files
    Last edited by jeffreybrown; 11-28-2012 at 03:46 PM.

  8. #8
    Registered User
    Join Date
    11-19-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VLOOKUP returning values with the most recent date

    Hi everyone,
    Could anyone please look at the attached file and tell me what I am doing wrong when applying a vlookup formula that is supposed to find items by the most recent date . When i'm trying to apply this formula to my file it doesn't seem to work correctly and I just can't figure out what the issue could be.

    I've attached the file Report.xlsx (i've cut out sensitive fields). I've applied the formula to column B on sheet POS. The value is supposed to be taken from column D on OBS sheet.

    e.g. Sheet POS row 10, pulls 29 for Location id 54. On sheet OBS, 29 is not the value for the most recent date of those available for location id 54.

    Please help.
    Attached Files Attached Files

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VLOOKUP returning values with the most recent date

    Take a look and see if this helps you.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-19-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VLOOKUP returning values with the most recent date

    Fotis1991 - thanks so much, works exactly how i need. THANKS!

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VLOOKUP returning values with the most recent date

    You are welcome.

    Thanks for the reb*

  12. #12
    Registered User
    Join Date
    11-18-2021
    Location
    England
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: VLOOKUP returning values with the most recent date

    Hello.

    My first post, but this has been driving me mad.
    Not an expert at Excel but using the LOOKUP formula given above I've managed to get the attached sheet almost working.
    I've two sheets that use external data and need the longest due date (column E) to be populated in the order ready (column B).

    Hope somebody can help, I'm sure it's a simple task for someone in the know.

    Thanks.
    Attached Files Attached Files

  13. #13
    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,942

    Re: VLOOKUP returning values with the most recent date

    Quote Originally Posted by chowe View Post
    Hello.

    My first post, but this has been driving me mad.
    Not an expert at Excel but using the LOOKUP formula given above I've managed to get the attached sheet almost working.
    I've two sheets that use external data and need the longest due date (column E) to be populated in the order ready (column B).

    Hope somebody can help, I'm sure it's a simple task for someone in the know.

    Thanks.
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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

+ 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