Add X amount of days to a date Excluding certain days of week? i.e monday or tuesday

Joined
Feb 25, 2013
Messages
10
Hello!

I have visited perhaps every single excel forum post in the entire interwebs that is vaguely related to my excel problem and I cannot find an answer to my query. So, I thought I would just bite the bullet and ask for directions!

I'll try and summarise my project first of all to give you an idea of what i'm working with.

I'm creating a calculator that will determine what date an employee will go onto half-pay due to sickness.

Based on the rule that a full-time employee is entitled to 130 working days absent a year before their pay is reduced to half, this is pro-rated for part-time employees i.e if you work 4 days a week you are entitled to 104 working days absent before you go onto half-pay.

The calculator begins with an option to select how many days you work a week, and based on that input, it determines the amount of absent days you are entitled to.

Then you select the actual days you work; the days of the week are listed and there is a 'YES/NO' drop down selection.

Then the employee inputs their 'spells of absence' which have the start date and end date of an absence. I used this formula to determine the number of working days (based on their inputted work pattern) that they were absent;

=IF(E21="","",SUM(IF(ISERROR(MATCH(WEEKDAY(ROW(INDIRECT(E21&":"&G21))),ExcludeDaysOfWeek,0)),1,0)))

Where E21 is the start date of the absence and G21 is the end date.

'ExcludeDaysOfWeek' is a range which lists the days the employee doesn't work, based on their 'YES/NO' selection.

So to summarise, it counts working days, excluding week days that the employee doesn't work.

Sorry for rambling, but I think background information is necessary for things like this!

Now on to my problem.

Once i've worked out how many days they have been absent based on their working pattern, I need to compare that to how many days they are entitled to, which we worked out at the start! i.e 130 days if you work 5 days a week, 104 if you work 4 days etc. So if an employee works 5 days a week, and they have been absent 125 days, the calculator would work out their 'half-pay date' as 5 working days from their 125th day of absence, to bring them up to 130 days. I'm not sure if this makes sense outside of my own brain.

Basically the bit i'm stuck on is, if an employee works 3 days, monday, wednesday, thursday, meaning they are entitled to 78 days absent, and they've been absent 58 days, HOW can i get excel to count forward those 20 days using only the days the employee works i.e monday, wednesday, thursday! I have tried using my ExcludeDaysOfWeek range from earlier, but it just won't work!

Basically I just need a function that will let me (end_date of latest absence, days left at full pay, (excluding days they don't work)

If anyone can assist me I will give you all the internets.

Long time lurker, please don't let me down Lords of the world wide web
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Did you find an answer? If you have Excel 2010 you can use WORKDAY.INTL function or in earlier versions you can use an array formula like this

=A1+SMALL(IF(ISNA(MATCH(WEEKDAY(A1+ROW(INDIRECT("1:"&B1*7))),ExcludeDaysOfWeek,0)),ROW(INDIRECT("1:"&B1*7))),B1)

Where A1 is the start date, B1 the number of days to count forward and ExcludeDaysOfWeek is defined the same way as before

This formula needs to be confirmed with CTRL+SHIFT+ENTER

Paste it in a cell - press F2 key to select formula then hold down CTRL and SHIFT keys while pressing ENTER. If done correctly you will see curly braces like { and } around the formula in the formula bar and formula should return the correct date
 
Last edited:
Upvote 0
Upvote 0
Barry, unfortunately this was an excel 2007 problem.

Looks like Rick gave you an excellent solution.......but just to clarify, my suggested formula will work OK in Excel 2007

......and reading further elsewhere I see that you wanted a version that will allow adding or subtracting days. My suggested formula can be modified to do that too, i.e.

=A1+SIGN(B1)*SMALL(IF(ISNA(MATCH(WEEKDAY(A1+ROW(INDIRECT("1:"&ABS(B1)*7))*SIGN(B1)),ExcludeDaysOfWeek,0)),ROW(INDIRECT("1:"&ABS(B1)*7))),ABS(B1))

still needs "array entry".

caveats: it doesn't allow B1 to be zero (although you could easily add an IF function to cover that possibility) and it doesn't allow for holidays, but apart from that (:eeek:) it gives me the same results as Rick's UDF
 
Last edited:
Upvote 0
Looks like Rick gave you an excellent solution
Thanks, but all the credit for that code should go to Chip Pearson... he wrote the original code... all I did was decipher how it worked (easy to do as it had a clear and logical layout), removed a section of code that tested and then errored out for negative values in the DaysRequired argument, and then patched 3 lines of code to make the negative values work correctly.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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