+ Reply to Thread
Results 1 to 8 of 8

determine total overlap time when there are gaps in overlap (4 date ranges)

  1. #1
    Registered User
    Join Date
    03-08-2014
    Location
    San Diego
    MS-Off Ver
    Excel 2010
    Posts
    4

    determine total overlap time when there are gaps in overlap (4 date ranges)

    Good afternoon,
    This is my first post to excel forum; thank you in advance for any assistance.

    I have rows of people and columns with start-end dates of 4 different medications (9 columns total, see example attached). I need to do 2 things:
    1. Determine if there is a gap in coverage between medication. As long as the coverages overlap in some way shape or form, that's good: I need to know if there is a time frame between first start date and last end date where there is no medication ordered.
    2. if there is a gap, I need to calculate the total coverage time for any/all meds that DOES NOT incorporate the time of gaps in medication ordered.

    I can;t figure out how to address the gap (if there is one).
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    Hello and welcome
    I had a look and could suggest a macro solution. My issue with the formula is the potential of medicine periods to overlap, so I am thinking of reversing the calculation and removing days between the start and end dates that are covered.
    Let me know if that will be suitable

    Regards
    Most helpful to mark solved items as such (see help for directions). Star ratings are always welcome.

  3. #3
    Registered User
    Join Date
    03-08-2014
    Location
    San Diego
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    I can't figure it out so if you can, great! There will not be many periods of NON-overlap, but when people are on 4 medications during a month time frame, the potential becomes larger and I need to account for it. If you could walk me through a macro, that would be fine: its maybe a sign I need to get myself up that next level in my data querying techniques.

  4. #4
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    Hello
    I have attached the spreadsheet with the macro, I wrote it in pieces so I hope it is not too difficult to follow.
    The main logic is to create an array with 2 dimensions. All the dates from the start to the end are filled in.
    Then the medicine 1 to 4 dates are examined and where they match, the array is updated with a 1.

    At the end, there is a comparison to see if all the elements had a 1 (i.e. sum of all the 1s should equal to duration between start and end dates). If so, there is no gap, otherwise there is a gap.

    I removed the rest of the dates by rounding down, i.e. the hours, minutes and seconds parts and assuming you are looking for a gap in a day and not hours or minutes.

    Regards
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-08-2014
    Location
    San Diego
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    Thank you ham jam. I am trying to figure the macro out. Unfortunately the time may be an issue, because even a gap of 10-12 hours would be significant. I have added to your reputation, but may have a question tomorrow after reviewing and checking a bit.

  6. #6
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    Hello
    The main calculation can be expanded to break the gap into an hourly gap as opposed to daily gap. That was not apparent from the initial request.
    Please define more definately what your definition of a gap is, is that 10 hours or 12 hours ?
    Does that apply generally, i.e. to all medicines ?

    Regards
    Tamas

  7. #7
    Registered User
    Join Date
    03-08-2014
    Location
    San Diego
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    HI Tamas, the VBA seems to be working so I have marked this thread as solved. THANK YOU! To answer your question, people should be on at least 1 medication throughout their visit. What can happen is someone cancels one medication but forgets to order another for a few hours or even sometimes not until the next day. I am trying to capture that time frame (can be hours, can be minutes, can be zero) where a person is not ordered at least 1 of the 4 medications. Does that make sense?

  8. #8
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: determine total overlap time when there are gaps in overlap (4 date ranges)

    Hello
    I interpreted the problem as trying to find the gap, in the case say antibiotics and you need the daily course and skipping a day creates a gap.
    In this case, a different logic would be required - perhaps where you subtract the start and end dates from each other and check for positive value constituting a missing time period. You may be able to achieve that with formula if you add a few more columns.
    Perhaps try that ?

    Regards

+ 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] Overlap between two time ranges
    By LondonJames in forum Excel General
    Replies: 11
    Last Post: 07-12-2019, 02:18 AM
  2. Calculate total hours if time ranges overlap
    By jl_stewart in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-03-2013, 10:21 PM
  3. Replies: 0
    Last Post: 08-14-2013, 11:21 AM
  4. Determining the % of overlap in two date ranges
    By eddienole in forum Excel General
    Replies: 3
    Last Post: 07-29-2011, 04:45 PM
  5. formula to determine time range overlap?
    By William DeLeo in forum Excel General
    Replies: 0
    Last Post: 06-06-2006, 03:26 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