workday, but even more flexible

panostis

New Member
Joined
Feb 29, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello there, =WORKDAY(E3+5,1,G2:G3) is really helpful. It's a way to negate the obsessive compulsion of "workday" to not include weekends when counting (I suppose there could be cases when this would be useful too). Thanks for that, and many other suggestions I have found on your site from time to time.
Would you be so kind as to offer your invaluable knowledge once again please?
I need =WORKDAY(E3+5,1,G2:G3) keep doing what it does (ie count weekends and holidays when adding days, but jump to very next working day if you reach the end of your calculation on them), but I also need it to be able to completely ignore/exclude/don't count at all say a month or predefined ranges of dates (in other words to behave as these aforementioned ranges do not exist at all.
So the formula should act as if a range (let's say August or some consecutive dates in A2:A5 & B2:B5) don't exist at all.
That is to say the formula should not include those dates when counting at 31/7 (the very last day when counting) and resume counting days at 1/9.
the same goes for the predefined ranges of consecutive dates in A2:A5 & B2:B5). They are to be excluded completely from counting and landing similarly to August.
What is more the resulting date cannot be (ie August or one of those predefined consecutive dates in ranges A2:A5 & B2:B5), but I guess this goes without saying.
In sort I would like to include weekends and holidays in my calculation (ie count them when adding days, but go to next working day if my calculation ends on them) and at the same time define some predefined ranges which should be ignored/skipped completely when counting as if they didn't exist at all (basically stop counting at the beginning of a range of dates and resume counting just after the last date in that range).
I would like to thank you for any ideas you may come up with as well as for the time you might spend doing it.
I've searched and searched for an answer and tried ways to accomplish the above but I am missing the advanced knowledge to do it on my own.
Sincerely,
Panos

a more flexible workday.xlsx
ABCDEFGHI
1Ignore dates below completely (don't count/don't land on them)Ignore dates below completely (don't count/don't land on them)2Ignore August completely (don't count/don't land on a date in August)holidays to be included when counting but then if the result lands on them go to next workingColumn3some examples to demonstrate what I meanColumn4Column5Column6
202/07/202417/07/202401/08/202423/07/2024
303/07/202418/07/202402/08/202429/07/2024start dateadd dayslanding date
404/07/202419/07/202403/08/202401/07/20242224/07/2024Τετάρτηneed this to be 31/7/2024 (ie not count blue at all! Start counting from 6/7/ to 16/7 =11days. then stop again at 17/7-20/7 and resume at 21/7 concluding 22 days at 31/7)
505/07/202420/07/202404/08/202401/07/2024203/07/2024Τετάρτηneed this to be 8/7/2024 (ie not count blue at all! Start counting two days at 6/7 landing on 7/7 which is a Sunday and should go to next working day)
605/08/202401/07/20241819/07/2024Παρασκευήneed this to be 30/7/2024 (ie not count blue at all! Start counting at 6/7 to 16/7 = 11days then resume counting the remaining 7 days at 21/7 reaching 27/7 which is a Saturday and should go on 29/7 monday but again this is a holiday, which we count normally but go to next working day)
706/08/202401/07/20243031/07/2024Τετάρτηneed this to be 9/9/2024 (ie not count blue at all! don't count August at all! Count weekends, count orange holidays but go to next working day if it lands on them
807/08/2024
908/08/2024
1009/08/2024
1110/08/2024
1211/08/2024this works for weekends and holidays (ie it counts them when calculating but if it lands on them skips to next working day. But I cannot make it exclude/ignore completely from counting predefined ranges)
1312/08/2024A=WORKDAY($G4+$H4-1;1;$D$2:$D$3)
1413/08/2024
1514/08/2024this only works for many prefefined blue ranges (ie excludes/ignores them completely from counting when calculating. Cannot put weekends and orange holidays in it (ie count weekends and orange holidays but go to next working day if it lands on them)
1615/08/2024B=WORKDAY.INTL(G4;H4;"0000000";SMALL((A2:A5;B2:B5;C2:C32);ROW(INDIRECT("1:"&COUNT(A2:A5;B2:B5;C2:C32)))))
1716/08/202431/07/2024
1817/08/2024
1918/08/2024is there a way to merge A and B and make it behave in a way that it combines both behaviours ?
2019/08/2024A) count weekends and orange holidays when calculating but go to next working day if the calculation ends on them
2120/08/2024B) avoid/ignore completely blue ranges. Don't even count when calculating but stop counting and resume after the range has ended and again the same for next blue range. Keep doing so until we have counted x number of days.
2221/08/2024
2322/08/2024
2423/08/2024
2524/08/2024
2625/08/2024
2726/08/2024
2827/08/2024
2928/08/2024
3029/08/2024
3130/08/2024
3231/08/2024
Sheet1
Cell Formulas
RangeFormula
G4G4=WORKDAY($E4+$F4-1,1,$D$2:$D$3)
H4:H7H4=TEXT($G4,"ηηηη")
G5:G7G5=WORKDAY($E5+($F5-1),1,$D$2:$D$3)
I17I17=WORKDAY.INTL(E4,F4,"0000000",SMALL((A2:A5,B2:B5,C2:C32),ROW(INDIRECT("1:"&COUNT(A2:A5,B2:B5,C2:C32)))))


Also asked here WORKDAY on steroids
 

Attachments

  • 1709225642037.png
    1709225642037.png
    204.7 KB · Views: 17
Last edited by a moderator:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I do not quite follow what you want. If you want to exclude additional dates, you can either add them to the holidays list, or keep them separate, and VSTACK them with the holidays, like this:
MrExcel_20240229.xlsx
EFG
3start dateadd dayslanding date
47/1/2024229/12/2024
Sheet3
Cell Formulas
RangeFormula
G4G4=WORKDAY($E4,$F4,VSTACK($D$2:$D$3,TOCOL($A$2:$C$32,,TRUE)))

But double check your end dates. If we find the working day that is 22 days beyond July 1, it is September 12 after excluding all of the extra days, holidays, and weekends.
 
Upvote 0
I think I misread your problem description. Have a look at this version 2.0...we use WORKDAY.INTL to declare all days of the week as workdays, including Saturdays and Sundays, but exclude the blue cells. That allows us to determine the date some days in the future. Then we subtract one from that date and look for the next workday using the WORKDAY function, which will recognize weekend days of Saturday and Sunday, and we include the orange holidays dates in the exclusion list also. This will then either jump forward to our original landing date determined by WORKDAY.INTL, or if that landing date is a weekend or a holiday, we'll jump forward to the next working day.
MrExcel_20240229.xlsx
EFGH
3start dateadd dayslanding datelanding date v2.0
47/1/2024229/12/2024Wed, 7/31/2024
57/1/202427/9/2024Mon, 7/8/2024
67/1/2024189/6/2024Tue, 7/30/2024
77/1/2024309/24/2024Mon, 9/9/2024
Sheet3
Cell Formulas
RangeFormula
G4:G7G4=WORKDAY($E4,$F4,VSTACK($D$2:$D$3,TOCOL($A$2:$C$32,,TRUE)))
H4:H7H4=WORKDAY(WORKDAY.INTL($E4,$F4,"0000000",VSTACK(TOCOL($A$2:$C$32,,TRUE)))-1,1,$D$2:$D$3)
 
Upvote 0
The following simpler formula returns the expected results for the posted dataset:
Excel Formula:
=WORKDAY(WORKDAY.INTL(E4,F4,"0000000",$A$2:$C$32)-1,1,$D$2:$D$3)
 
Upvote 0
Thanks @Tetra201...I didn't realize the "holidays" option would accept a multi-column range reference (I should have tried that).
 
Upvote 0
I see. Just had the opportunity to put the formula to work and it does work for the great majority of scenarios. There was actually a scenario where if the calculation ended on a weekend and then the following Monday was a normal holiday (counted but go to next day), the end day would skip to Tuesday even though that Tuesday was in the column of dates to be excluded completely from calculations and would stay there not forwarding to Wednesday as it should. I found that this is something very rare and unlikely to come across in real life scenarios, but the way to fix it is to expand the "holidays" parameter of the workday function so that it doesn't only include the column of normal holidays but rather all columns (ie columns of dates to be completely excluded when counting as well as column of normal holidays). So the formula above would work even for that 1% of cases if changed to =WORKDAY(WORKDAY.INTL(E4,F4,"0000000",$A$2:$C$32)-1,1,$A$2:$D$3) . Not quite sure why that is though. I am sure you probably understand why this seems to work better... Be that as it may I would like to offer my gratitude and thank you very much for sharing a working solution. I guess simplicity is the secret to perfection. Much obliged for your time and effort sir(s). Problem solved!
 
Upvote 0
You're right...good catch. After the first step to determine the initial landing spot (this counting process does count holidays but excludes A:C), we then go back one day and look for the next working day subject to whatever constraints you want. In this case, the next legitimate working day cannot land on any of the A:C dates or the holidays in D, so expanding the last argument to A:D will do that, but adjust the range of the last argument to cover all of the A:C dates and all of the D dates, so rather than A2:D3, it would be A2:D32 in this example case...
Excel Formula:
=WORKDAY(WORKDAY.INTL(E4,F4,"0000000",$A$2:$C$32)-1,1,$A$2:$D$32)
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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