List of consecutive start and end date ranges, concatenating them and conditional checking

Lekazard

New Member
Joined
May 25, 2023
Messages
11
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I have been given an excel task which involves functions and VBA which is beyond my skills. Any help solving this would be highly appreciated

I have a table structured as shows:

UserIDStartDateEndDateVacationDays
A40143530.12.202131.12.202126.12.2021
A40147727.12.202128.12.202129.12.2021
A40147729.12.202131.12.2021
A40371327.12.202128.12.2021
A40397630.12.202131.12.2021
A40537823.12.202123.12.2021
A41002431.12.202131.12.2021
A41002629.12.202131.12.2021

So the task which I'm trying to solve is this: I have a monthly list of all the vacations our staff applied for and granted. Regarding vacation days there's a condition, that if there's a midweek holiday the middle of the vacation period that person will be then granted an extra vacation day. So far my colleagues have been looking for those special cases manually by using different filters which is tedious and slow. So the aim here is to create a macro or a formula which checks the conditions against the monthly list and tell's whether the UserID is granted an extra vacation day or not.
The data is gathered monthly. A single UserID can apply for multiple vacation periods so row A has duplicates. Also the extra vacation day has the conditions, that there needs to be at least 1 regular day before and 2 after the midweek holiday OR 2 days before and 1 after.
I assume the WORKDAY.INTL function could be used here, but to make it a bit simpler I have created the column D where the midweek holidays are manually inserted (there are usually not so many in one month, so adding them manually into the sheet is relatively fast).
So in theory what needs to be done, is first to check through duplicates in column A, merge together the vacation periods if they are consecutive, and then check if the actual vacation period meets the conditions. For example in the sample without merging A401477 doesn't meet the conditions since 29.12.2021 seems to be the same as StartDate, but when those two date ranges are put together, his/hers actual vacation period is 27.12.-31.12. and in this case 29.12. fulfills the rule of 2+1 days and will be granted an extra vacation day.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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