Merging Overlapping date ranges for each id

motherindia

Board Regular
Joined
Oct 15, 2015
Messages
218
Hello Sir,

I Have list of Start date and end Date for each custmer . Column A contains Cust ID and other 2 columns contain Start date and End Date. Basically I need to combine start date and end date if the dates are overlapping each otherand date are consecutive or dates are duplicated else it should remain same.

Following is the Data on SHeet1 and Output sheet should on another sheet.
Data on Sheet1

Cust no Start Date End Date
1111111 23-08-16 25-08-16
1111111 22-08-16 22-08-16
1111111 08-11-14 02-12-16
2222222 12-10-16 30-11-16
2222222 20-07-16 30-09-16
2222222 14-02-16 23-02-16
2222222 14-02-16 23-02-16


Output on Sheet2

Cust no Start Date End Date
1111111 08-11-14 02-12-16
2222222 12-10-16 30-11-16
2222222 20-07-16 30-09-16
2222222 14-02-16 23-02-16

Regards,
motherindia
 
You're welcome

After a more careful review I have found one more problem :P If the range is longer than a day it deducts it to one day. Let me show it in an example;


Original Data;
1111 05.01.2017 09:30 08.01.2017 17:30

After the macro;
1111 05.01.2017 09:30 05.01.2017 17:30
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
That's because the code was based on finding contiguous times, based on unique individual dates, not multiple dates.
If you would like me to amend the code, please supply some basic dates/times with expected results.
.
 
Upvote 0

Forum statistics

Threads
1,215,641
Messages
6,125,983
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top