+ Reply to Thread
Results 1 to 9 of 9

Two lists, if same dates and inbetween start and end times

  1. #1
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Two lists, if same dates and inbetween start and end times

    I have two worksheets in the same workbook.

    On Worksheet 1, I have a date in Column B and time in Column C.

    On Worksheet 2, I have a date in Column A and start time in Column C and end time in Column D.

    What I am trying to do:
    1. In worksheet 1. Compare Worksheet 1's date to the list of dates in worksheet 2. (there is going to multiple of the same date in Worksheet 2).
    2. If the dates are the same, then I need it compare the times. I need to know if Worksheet 1's time is equal to or in between the Worksheet 2's Start and End Time.
    3. If it is in between, then I want it to return the value of Worksheet 2: Column E's value of that same row.
    4. If it is not in between, then it should go to the next matching date in the list (as there are multiple of the same dates in worksheet 2).
    5. If there is not another matching date, then return blank.

    I have googled and since this is a multi-faceted request, I have found it hard to figure it out.

    I appreciate any help / guidance.

    -Stearno

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,838

    Re: Two lists, if same dates and inbetween start and end times

    Try

    in E2 of Sheet1 (assuming data starts in row 2 on both sheets)

    =IFERROR(INDEX(Sheet2!$E$2:$E$100,SMALL(IF((Sheet2!$A$2:$A$100=Sheet1!$B3)*(Sheet2!$C$2:$C$100<=Sheet1!$C3)*(Sheet2!$D$2:$D$100>=Sheet1!$C3),ROW(Sheet1!$B$2:$B$100)-ROW($B$2)+1,""),1)),"")

    Enter with Ctrl+Shift+Enter

    Assumes only one valid match on date/time for a given date

  3. #3
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: Two lists, if same dates and inbetween start and end times

    John,
    Thanks for the formula.

    First, I copied the formula into Sheet1 E2 cell in the text field. I hit Ctrl + Shift + Enter. I then highlighted the cells below the cell where I just put the array, and clicked Fill Down on the Editing section of the Home tab.

    I put It is not producing any information in the field. I have attached my sheet so as to make this easier.

    Second, I would like to learn from what you did as well.

    Let me explain my understanding of your formula to see if I have understood it correctly. The logic says:
    if the cell in Sheet1 Column B is = to the first cell that it comes across in array Sheet2!A2:A42939
    if it finds the same date, then if the cell from the same row in array Sheet2!C2:C42939 is < Sheet1 Column C and Sheet2!D2:D42939 > Sheet1 Column C
    then return the row from Sheet1 - the starting cell number.

    Note: I changed it from <= and >= to just < and >. Because I want to include if it is equal to. If I must be in between the start and end time, I also want to consider it in between when it is also equal to. Am I correct in understanding?

    Two questions about the formula:
    1) It seems to me that it if the date matches, the Sheet1 time is in between the Column C and Column D times, then the formula returns the number of rows away from Sheet1 Column B2 where it found this match. Am I correct?
    Instead, what I want to return is shown in row 6 on Sheet1. If the 3 conditions are correct, I want it to return Sheet 2 Column E into the cell of Sheet 1 Column E.

    Thanks,
    Stearno

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,838

    Re: Two lists, if same dates and inbetween start and end times

    No attachment.

    to upload file click "Go Advanced" then scroll down to "Manage Attachments"

  5. #5
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: Two lists, if same dates and inbetween start and end times

    Wow, thats a surprise. I now know it was because it was 'too big'. To get around that, here it is: https://dl.dropboxusercontent.com/u/...-myfxbook.xlsx

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,838

    Re: Two lists, if same dates and inbetween start and end times

    Please post a cut-down version here as many members will not visit file-hosting sites.

  7. #7
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: Two lists, if same dates and inbetween start and end times

    Sorry. Here you go.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,838

    Re: Two lists, if same dates and inbetween start and end times

    Two changes:

    in Column C on Sheet1 to get the correct time (your times were incorrect)

    =MOD(B2,1)

    copy down

    In Column E

    =IFERROR(INDEX(Sheet2!$E$2:$E$157,SMALL(IF((Sheet2!$A$2:$A$157=INT(Sheet1!$B2))*(Sheet1!$C2>=Sheet2!$C$2:$C$157)*(Sheet1!$C2<=Sheet2!$D$2:$D$157),ROW(Sheet2!$B$2:$B$157)-ROW($B$2)+1,""),1)),"")

    Enter with Ctrl+Shift+Enter

    Your date in B is a date /time so we need to "remove" the time when comparing.
    Attached Files Attached Files
    Last edited by JohnTopley; 09-21-2016 at 04:55 AM.

  9. #9
    Registered User
    Join Date
    09-19-2016
    Location
    Muscat, Oman
    MS-Off Ver
    365
    Posts
    56

    Re: Two lists, if same dates and inbetween start and end times

    That worked! THank you so much for your valuable help!

    -Stearno

+ 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] Averaging the earliest start times and latest end times for multiple days
    By kbiro in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-26-2016, 02:15 PM
  2. [SOLVED] Gantt chart conditional formatting when start and end dates contain times
    By Crimsonhobbit in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2016, 06:59 AM
  3. Replies: 3
    Last Post: 08-07-2015, 11:24 AM
  4. Replies: 21
    Last Post: 05-11-2015, 03:53 PM
  5. Macro to Work out dates inbetween
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2013, 11:14 AM
  6. [SOLVED] find data inbetween dates
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2013, 09:03 AM
  7. =sum inbetween 2 dates used in v lookup
    By Dave_A in forum Excel General
    Replies: 1
    Last Post: 03-02-2007, 10:44 PM

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