+ Reply to Thread
Results 1 to 14 of 14

Find corresponding date range based on single date and ID number

  1. #1
    Registered User
    Join Date
    03-28-2014
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    6

    Find corresponding date range based on single date and ID number

    Hi, hope that you can help me with this one.
    I'm trying to combine the hours that a employee worked on a single date, with one of multiple time periods that exist for that employee.

    I have two sets of data.
    Set 1 (hours)
    Employee number, date, hours
    12345, 1-2-2014, 6
    12345, 1-3-2014, 8
    12345, 1-10-2014, 8

    Set 2 (periods)
    Employee number, start date, end date
    12345, 1-1-2014, 4-1-2014
    12345, 6-1-2014, 1-2-2014

    What I'd like to do is to add the start and end date of Set 2 to Set 1 for every row in Set 1

    In above example the result should be like this.
    12345, 1-2-2014, 6, 1-1-2014, 4-1-2014
    12345, 1-2-2014, 8, 1-1-2014, 4-1-2014
    12345, 1-10-2014, 8, 6-1-2014, 1-2-2014

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Find corresponding date range based on single date and ID number

    Excel will never know what dates (from set 2) to add to what records (in set 1), because the employee number is not unique and even if you concatenate employee number with (date/start date), there is no matches because the start date in set 2 is different to the date in set 1.

    There is no logical combinations in the data sample you provided.

  3. #3
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Find corresponding date range based on single date and ID number

    are the employee numbers unique in each of the sheets?
    Click on the star if you think I helped you

  4. #4
    Registered User
    Join Date
    03-28-2014
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find corresponding date range based on single date and ID number

    The first sheet contains per employee number the hours per day
    The second sheet contains the diferent periods for that employee
    In the example I've used just one employee (12345), the same is used in both sheets

  5. #5
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Find corresponding date range based on single date and ID number

    Can you upload sample file and desired results.
    Appreciate the help? CLICK *

  6. #6
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Find corresponding date range based on single date and ID number

    I doubt this is correct as I still don't understand the set1 vs. set2 data.

    Lookup.xlsx

  7. #7
    Registered User
    Join Date
    03-28-2014
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find corresponding date range based on single date and ID number

    The sample file contains a bit more.
    And please e aware of the European date format :-)

    Tnx
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-28-2014
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find corresponding date range based on single date and ID number

    What it "basicly" has to do is look for the periods of that employee and finding the previous date (based on the date in sheet/set 1) that is available, and show it as 1st day.
    For the end day it should find te next available day in the slection of periods for that employee.

  9. #9
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Find corresponding date range based on single date and ID number

    See the result...
    It finds matches, but only for a few...

    sample_upload.xlsx

  10. #10
    Registered User
    Join Date
    03-28-2014
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find corresponding date range based on single date and ID number

    yeah, I came that far. Thanks though.
    I finds it when the date in the first sheet is found in the second.
    But if it can't find it, it has to find the first date before that in the available selection of the employee

  11. #11
    Registered User
    Join Date
    03-28-2014
    Location
    Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find corresponding date range based on single date and ID number

    I found a other thread with a formula that can return a previous date based on a given name and date.
    I can't seem to understand it and use it on my own.

    The used formula is:
    =INDEX(PURCHASE!$A$1:$D$42,MATCH($A2,IF((PURCHASE!$B$1:$B$42=SALE!$B2),PURCHASE!$A$1:$A$42),1),{1,2,4})

  12. #12
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Find corresponding date range based on single date and ID number

    I'll look at that formula...but on my way out now...

    I came closer with this, but it is not a good solution and I wouldn't recommend using it!!
    =IFERROR(VLOOKUP(A2&B2,Periods!$A$2:$E$5,3,0),D1)

  13. #13
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Find corresponding date range based on single date and ID number

    A modified solution seems to do the job...
    See attached...

    sample_upload solution.xlsx

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: Find corresponding date range based on single date and ID number

    You can also use a LOOKUP formula:

    =IFERROR(LOOKUP(2,1/(Periods!$A$2:$A$200=$A2)/(Periods!$B$2:$B$200<=$B2)/(Periods!$C$2:$C$200>=$B2),Periods!B$2:B$200),"")

    Adjust the ranges to suit.
    Remember what the dormouse said
    Feed your head

+ 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] Single column countif with moving range based on today's date
    By JonesyCC in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-16-2013, 02:45 PM
  2. Replies: 0
    Last Post: 05-30-2013, 07:50 PM
  3. [SOLVED] find missing date on every group date list based on range and criteria
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2013, 01:26 AM
  4. [SOLVED] Date Filter based on Cell Input - single date or range of dates
    By babaloo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2012, 10:32 AM
  5. Set a month as range based on single date in one cell
    By mexcel300 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2011, 10:52 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