+ Reply to Thread
Results 1 to 4 of 4

Lookup based on name and date

  1. #1
    Registered User
    Join Date
    03-16-2015
    Location
    Washington, DC
    MS-Off Ver
    Excel 2013
    Posts
    5

    Lookup based on name and date

    Hello all. Thanks for taking the time to look at this.

    I need to do a dependent lookup. On one sheet, I have four columns: Name, Date, Election Type, Election Amount. The first two of these columns are populated. Our goal is to populate the latter two columns.

    On the second sheet, we have: Name, Election Type, Election Amount, and Effective Date. Now, in the original document, I'm working with about 100,000 rows in the first sheet, and even more on the second. (Yeah, there are likely better programs for this, but this is what we've got). I need to populate the empty rows of the first sheet by looking up the data on the second by name, and then finding the data that is closest to AND earlier than the date given on the first sheet.

    So, for example, if the "Date" on the first sheet is 10/14/14, we need to look at the second sheet, first find the appropriate name, and then find the data with the closest "Effective Date" without going over 10/14/14.

    I have attached a small example, complete with how the data should look when it's correct. For simplicity's sake, there is only one name in the example, but there are thousands in the original. I feel as though this should be somewhat straightforward, but I'm having a heck of time coming up with the appropriate logic here. Anyone have any ideas? Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: Lookup based on name and date

    Try (untested)

    in C2
    =VLOOKUP(A2,IF(B2=Sheet2!D$2:D$8,Sheet2!A$2:D$8,""),3,0)

    in D2
    =VLOOKUP(A2,IF(B2=Sheet2!D$2:D$8,Sheet2!A$2:D$8,""),4,0)

    Array formulas, use Ctrl-Shift-Enter
    Last edited by Special-K; 03-17-2015 at 01:12 PM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    03-16-2015
    Location
    Washington, DC
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Lookup based on name and date

    Special-K, thank you for an accurate and timely response. It is deeply appreciated.

    For anyone with a free second and the inclination, is there a relatively simple explanation of array formulas?

  4. #4
    Registered User
    Join Date
    03-16-2015
    Location
    Washington, DC
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Lookup based on name and date

    Unfortunately, the formulas you've provided only work in those situations in which there is an exact match between the date on the first page and the date on the second. If there is no match, it returns no data.

    Ultimately I need a formula that will, using the date from the first page, find the closest date on the second page (without going over) and return the corresponding data. I've managed to put together a formula (below) that sort of identifies the date we're looking for, but it doesn't adhere to my "no going over" rule. I'm also not sure how to implement it into the broader function.

    For example, placing the following in cell E3 (on Sheet 1) will pull the closest date on Sheet 2 to that from Sheet 1 which is under consideration:

    {=INDEX(Sheet2!$D$2:$D$8,MATCH(MIN(ABS(Sheet2!$D$2:$D$8-Sheet1!B3)),ABS(Sheet2!D2:D8-Sheet1!B3),0))}

    It is a middling effort at best, and may or may not be a step towards the final answer.

    So, to repeat, we need to populate columns C and D on Sheet 1 with the appropriate data from Sheet 2, using first the name in column A, and then by finding the date on Sheet 2 that is closest to, but not over, that of the row under consideration on Sheet 1.

    This is a tough one. Any help is sincerely appreciated.
    Last edited by Tacos_Tacos_Tacos; 03-17-2015 at 02:29 PM.

+ 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] Formula to lookup Date based on Date in cell D1
    By rizmomin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-23-2014, 05:36 PM
  2. [SOLVED] Formula to Lookup value based on date within a date range
    By MHamid in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-26-2013, 02:24 PM
  3. [SOLVED] Lookup date and condtional format colour based on date
    By Smudge.Smith in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-25-2013, 08:38 AM
  4. Replies: 2
    Last Post: 09-20-2010, 02:51 PM
  5. Lookup based on a date
    By mkvassh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-21-2009, 04:03 AM

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