+ Reply to Thread
Results 1 to 6 of 6

Help with VLOOKUP to return corresponding value from nearest date value

  1. #1
    Registered User
    Join Date
    05-21-2021
    Location
    Honolulu, HI
    MS-Off Ver
    2016
    Posts
    9

    Help with VLOOKUP to return corresponding value from nearest date value

    Our point in time reporting capabilities are lacking so hoping to find some help here.

    I have a list of employees who were active as of 3/31/21. On another tab is a list of pay history with effective dates for each rate of pay. I need to somehow pull in the salary value from the pay history tab where the effective date is closest to and/or less than 3/31/21.

    Based on the attached example, the correct value should be 74000 as this is the latest effective date which is nearest to but less than 3/31/21.

    Thank you in advance!
    sfoc
    Attached Files Attached Files
    Last edited by sfoc; 10-06-2021 at 06:26 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,601

    Re: Help with VLOOKUP to return corresponding value from nearest date value

    custom number format for C1: "Salary as of" m/d/yyyy
    Then in C2:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by protonLeah; 10-06-2021 at 07:19 PM.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    05-21-2021
    Location
    Honolulu, HI
    MS-Off Ver
    2016
    Posts
    9

    Re: Help with VLOOKUP to return corresponding value from nearest date value

    That solution would work in the example provided but with the live data containing thousands of unique employee ID's and dozens of effective dates per employee, there is a tendency for things to get a bit weird and wrong salaries are pulled in.

    Since we're dealing with a lot of unique file #'s, how can we incorporate the file # into the lookup value?
    Last edited by sfoc; 10-06-2021 at 07:43 PM.

  4. #4
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Help with VLOOKUP to return corresponding value from nearest date value

    Starting from Ben's post #2 workbook, in C2 please try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Relative to the prior vlookup() formula this formula adds a check that the filenames match.
    Edit: This is an array formula and must be committed via CTRL-SHIFT-ENTER

    Note that with both this and the prior vlookup() formula the sheet2 dates must be in chronological order.

    If this still doesn't do it, then please upload a representative data set that includes specific examples of any "weirdness" that we need to accommodate.
    Last edited by GeoffW283; 10-06-2021 at 09:34 PM.
    Geoff

    Did I help significantly? If you wish, click on * Add Reputation to say thanks.
    If your problem has been resolved please select ?Solved? from the Thread Tools menu

  5. #5
    Registered User
    Join Date
    05-21-2021
    Location
    Honolulu, HI
    MS-Off Ver
    2016
    Posts
    9

    Re: Help with VLOOKUP to return corresponding value from nearest date value

    Thank you Geoff...that worked like a charm!

    By any chance and based on your example, is there a way to also pull in the salary previous to the 74,000 in column D?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,377

    Re: Help with VLOOKUP to return corresponding value from nearest date value

    Maybe just this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel VBA 2016 32bit - Vlookup Date after date typed in and return value from named range
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-27-2017, 02:34 AM
  2. [SOLVED] vlookup between 2 worksheets, return yes/no if date is between date range
    By mmor5 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-05-2017, 03:09 PM
  3. [SOLVED] 2 Column Look Up / Match - Return Item on or to the nearest date
    By DHHM in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-02-2016, 06:55 AM
  4. Replies: 0
    Last Post: 11-16-2015, 08:57 AM
  5. [SOLVED] Function to return a date of the nearest same day
    By Bezzie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2014, 03:38 AM
  6. [SOLVED] Compare strings for match in separate worksheet and return nearest future date
    By kungfood in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 05:19 PM
  7. Replies: 8
    Last Post: 11-16-2006, 09:27 AM

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