Excel Workdays Formula (Specific)

JiveTurkey2123

New Member
Joined
Jan 25, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Hope all is well! I wanted to ask for a huge favor here with the workday formula.The first part of the IF is correct where E5=“CA”, however i need to fix the part where E5 does not equal CA (this part: IF(AND(AM5<>"N/A",AM5<>"??",AM5<>""),AM5-4,""))

=IF(E5="CA",(IF(AND(AM5<>"N/A",AM5<>"??",AM5<>""),WORKDAY(WORKDAY.INTL(WORKDAY(AM5,-3,Production!$N$108:$N$119),-3,11,Production!$N$108:$N$119)+1,-1,Production!$N$108:$N$119),"")),IF(AND(AM5<>"N/A",AM5<>"??",AM5<>""),AM5-4,""))

AM5 is start date
Production!$N$108:$N$119 is the holiday list


This part is working:
When E5=“CA”
This formula that will calculate 6 days in the past from the start date.
Sunday's cannot be included in the 6 day "count".
Monday-Saturday AND Holidays CAN be included in the 6 day "count".

This part is not working:
When E5 does NOT equal “CA”
This formula that will calculate 3 days in the past from the start date.
Sunday's cannot be included in the 3 day "count".
Monday-Saturday AND Holidays CAN be included in the 3 day "count".

However, out of the 3 total count days:
Day 0: cannot count Saturday, Sunday or Holiday's
Day 1-2: cannot count Sunday or Holiday's
Day 3: cannot count Saturday, Sunday or Holiday's
The final result start date can only land on a Monday-Friday and not on a holiday, Saturday or Sunday

Example:

If start date is 9/3/2024, should return 8/29/2024
Day 0: 8/29 (return date)
Day 1: 8/30
Day 2: 8/31
Day 3: 9/3 (start date)

9/1 doesnt count since its a Sunday
9/2 doesnt count since its a Holiday (Labor Day)

Example 2:
If start date is 9/16/2024, should return 9/12/2024
Day 0: 9/12 (return date)
Day 1: 9/13
Day 2: 9/14
Day 3: 9/16 (start date)

9/15 doesnt count since its a Sunday

Your help would be greatly appreciated!!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I'm trying to understand but your examples are not very clear to me.
When you say 3 days in the past starting from a date, what would be day 0, 1, 2, 3? Day 0 is the day you start from?
How would you like to count the days if the start day (day 0) is a Saturday? Lets say 09/07/2024 is the start day.
 
Upvote 0
I'm trying to understand but your examples are not very clear to me.
When you say 3 days in the past starting from a date, what would be day 0, 1, 2, 3? Day 0 is the day you start from?
How would you like to count the days if the start day (day 0) is a Saturday? Lets say 09/07/2024 is the start day.
The final result start date can only land on a Monday-Friday and not on a holiday, Saturday or Sunday
So for 9/7/2024, that cannot be a start date - it would have to be 9/6 or 9/9

Day 0: cannot count Saturday, Sunday or Holiday's
Day 1-2: cannot count Sunday or Holiday's
Day 3: cannot count Saturday, Sunday or Holiday's
 
Upvote 0
Assuming a lot of things... how about?:

Just watch the result in column AU (all in one). The other columns are how we got there.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1
2
3
4StartDay 0Day 2Day 3all in one
5CA03/09/2024 Tue03/09/2024 Tue30/08/2024 Fri29/08/2024 Thu29/08/2024 Thu
607/09/2024 Sat06/09/2024 Fri04/09/2024 Wed03/09/2024 Tue03/09/2024 Tue
716/09/2024 Mon16/09/2024 Mon13/09/2024 Fri12/09/2024 Thu12/09/2024 Thu
808/09/2024 Sun06/09/2024 Fri04/09/2024 Wed03/09/2024 Tue03/09/2024 Tue
902/09/2024 Mon(holiday)30/08/2024 Fri28/08/2024 Wed27/08/2024 Tue27/08/2024 Tue
Sheet2
Cell Formulas
RangeFormula
AO5:AO9AO5=WORKDAY(AM5+1, -1, Production!$N$108:$N$119)
AP5:AP9AP5=WORKDAY.INTL(AO5, -2,11, Production!$N$108:$N$119)
AQ5:AQ9AQ5=WORKDAY(AP5, -1, Production!$N$108:$N$119)
AS5:AS9AS5=WORKDAY(WORKDAY.INTL(WORKDAY(AM5+1, -1, Production!$N$108:$N$119), -2,11, Production!$N$108:$N$119), -1, Production!$N$108:$N$119)
 
Upvote 0
And you could define a named range named "Holidays" to Production!$N$108:$N$119
So your formula would look like this:

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1
2
3
4StartDay 0Day 2Day 3all in one
5CA03/09/2024 Tue03/09/2024 Tue30/08/2024 Fri29/08/2024 Thu29/08/2024 Thu
607/09/2024 Sat06/09/2024 Fri04/09/2024 Wed03/09/2024 Tue03/09/2024 Tue
716/09/2024 Mon16/09/2024 Mon13/09/2024 Fri12/09/2024 Thu12/09/2024 Thu
808/09/2024 Sun06/09/2024 Fri04/09/2024 Wed03/09/2024 Tue03/09/2024 Tue
902/09/2024 Mon(holiday)30/08/2024 Fri28/08/2024 Wed27/08/2024 Tue27/08/2024 Tue
Sheet2
Cell Formulas
RangeFormula
AO5:AO9AO5=WORKDAY(AM5+1, -1, Holidays)
AP5:AP9AP5=WORKDAY.INTL(AO5, -2,11, Holidays)
AQ5:AQ9AQ5=WORKDAY(AP5, -1, Holidays)
AS5:AS9AS5=WORKDAY(WORKDAY.INTL(WORKDAY(AM5+1, -1, Holidays), -2,11, Holidays), -1, Holidays)
Named Ranges
NameRefers ToCells
Holidays=Production!$N$108:$N$119AS5:AS9, AO5:AQ9
 
Upvote 0
Solution
And you could define a named range named "Holidays" to Production!$N$108:$N$119
So your formula would look like this:

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1
2
3
4StartDay 0Day 2Day 3all in one
5CA03/09/2024 Tue03/09/2024 Tue30/08/2024 Fri29/08/2024 Thu29/08/2024 Thu
607/09/2024 Sat06/09/2024 Fri04/09/2024 Wed03/09/2024 Tue03/09/2024 Tue
716/09/2024 Mon16/09/2024 Mon13/09/2024 Fri12/09/2024 Thu12/09/2024 Thu
808/09/2024 Sun06/09/2024 Fri04/09/2024 Wed03/09/2024 Tue03/09/2024 Tue
902/09/2024 Mon(holiday)30/08/2024 Fri28/08/2024 Wed27/08/2024 Tue27/08/2024 Tue
Sheet2
Cell Formulas
RangeFormula
AO5:AO9AO5=WORKDAY(AM5+1, -1, Holidays)
AP5:AP9AP5=WORKDAY.INTL(AO5, -2,11, Holidays)
AQ5:AQ9AQ5=WORKDAY(AP5, -1, Holidays)
AS5:AS9AS5=WORKDAY(WORKDAY.INTL(WORKDAY(AM5+1, -1, Holidays), -2,11, Holidays), -1, Holidays)
Named Ranges
NameRefers ToCells
Holidays=Production!$N$108:$N$119AS5:AS9, AO5:AQ9

This worked, thanks alot Legend!!
 
Upvote 0

Forum statistics

Threads
1,221,444
Messages
6,159,912
Members
451,601
Latest member
terrynelson55

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