
Originally Posted by
kanopy123
Hi
I have two sets of data in two sheets both containing time ranges (i.e start and end times). I need to be able to determine if a time range intersects the other time range and by how much and then sum the total number of minutes of that intersection. So given the following. I am writing some VBA code to transform the data and format it correctly so would prefer the answer in VBA but a cell function would work.
So given the following:
sheet1:
| A1 | B1 |
| 02:00 | 16:00 |
sheet2:
| A1 | B1 |
| 04:00 | 05:00 |
So i would want to determine the number of minutes that the sheet2 time range is within the sheet1 range.
The trouble is sheet2 time ranges could insect, overlap or be fully contained so the following examples could be possible:
1. 01:00 - 03:00 - intersect duration would be 60 minutes
2. 15:00 - 17:00 - intersect duration would be 60 minutes again
3. 01:00 - 19:00 - intersect duration would be 840 minutes
4. 12:00 - 14:00 - intersect duration would be 120 minutes
Have been racking my brains trying to find an easy way to determine this and I'm basically stuck.
Could anyone offer an insight?
Thanks
Simon
Bookmarks