+ Reply to Thread
Results 1 to 11 of 11

Time overlap detection

  1. #1
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Question Time overlap detection

    Hi,
    I want to detect time overlap (interference) in my dataset. I have provided a sample data file. As you see, there is Start date, End date, Start time, and End time columns which show each person's work information. There are some time overlap for each person in those columns. I want to write a VBA code for automating the detection process. Those rows which have interference with each other (for each person) should be detected and rewritten on a new sheet (the whole row should be rewritten).
    I couldn't imagine any VBA solution for this problem. I think I need to use VBA Dictionary Object, but I don't know how to implement it for this purpose.
    Please help me out. The solution would be very important in my work.
    Thanks.

    Untitled.png
    Attached Files Attached Files
    Last edited by fa2020; 11-08-2020 at 05:06 AM.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Time overlap detection

    according to this:

    https://docs.microsoft.com/en-us/off...tionary-object

    the dictionary is nothing more than a glorified array. you don't need that. you can use it, but it's not necessary. you can simplify it greatly. simply loop through the rows and check the dif between the vals in the 2 columns. you can probably make use of these functions:

    - datediff()
    - dateadd()
    - simple addition / subtraction

    but yes, an array would help because obviously there is more than 1 per person, and most have overlaps.

  3. #3
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Re: Time overlap detection

    I cannot use datediff() function because in the real world, the dates I use are Shamsi dates (example: 1399/08/18).
    I think VBA Dictionary/Array is the key for this purpose. But I don't know how to implement it for my problem.

  4. #4
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Time overlap detection

    do you know how to use the info on the KB page from MS, that I gave you, to your advantage?

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Time overlap detection

    Here is the code for macro. Result is in Sheet2
    Row number is given in J column.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Time overlap detection

    Please Login or Register  to view this content.
    Last edited by jindon; 11-08-2020 at 09:42 AM. Reason: Fixed a typo

  7. #7
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Time overlap detection

    you have concatenated vars of diff types here:
    Quote Originally Posted by kvsrinivasamurthy View Post
    Please Login or Register  to view this content.
    and in other places. that has never worked for me. furthermore, trying to concat in the ":" like you've done also has never worked for me. I get error after error. no pattern.

  8. #8
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Re: Time overlap detection

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    Unfortunately, When I tried some different situations, I noticed that this code has some glitches. I have provided an example which cause inaccurate result:
    Attachment 703323
    Your code detects this situation as overlapped time interval for Alex. How can it be revised?

  9. #9
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Re: Time overlap detection

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    Thanks Jindon, this code works fine. I can run it in my PC. But in my workplace PC, it gives error in the line below:
    Please Login or Register  to view this content.
    It says: Automation failed
    How can I solve this issue in my workplace PC?
    Last edited by fa2020; 11-09-2020 at 02:06 PM.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Time overlap detection

    Quote Originally Posted by fa2020 View Post
    Thanks Jindon, this code works fine. I can run it in my PC. But in my workplace PC, it gives error in the line below:
    Please Login or Register  to view this content.
    It says: Automation failed
    How can I solve this issue in my workplace PC?
    Is it working with your other PC?
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-03-2020
    Location
    US
    MS-Off Ver
    2019
    Posts
    85

    Re: Time overlap detection

    Quote Originally Posted by jindon View Post
    Is it working with your other PC?
    Please Login or Register  to view this content.
    Thanks. It's fine.

+ 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. Time overlap
    By julleke in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-08-2017, 10:30 AM
  2. Time Overlap Not working for few time range. Please help
    By pradeepn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-21-2016, 02:43 AM
  3. [SOLVED] Time overlap
    By aanaduta in forum Excel General
    Replies: 6
    Last Post: 09-15-2015, 12:13 PM
  4. Time overlap %
    By sfire184 in forum Excel General
    Replies: 5
    Last Post: 09-09-2014, 02:23 AM
  5. [SOLVED] determine total overlap time when there are gaps in overlap (4 date ranges)
    By miriambender in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-12-2014, 11:58 PM
  6. [SOLVED] Match Function for detection of 10-90 rise time
    By bubbletea2 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-09-2013, 03:16 AM
  7. Replies: 0
    Last Post: 08-14-2013, 11:21 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