If And Or—What To Use When

MrDB4Excel

Active Member
Joined
Jan 29, 2004
Messages
348
Office Version
  1. 2013
Platform
  1. Windows
I have a sheet showing order dates whereby the “Order Delivery Date” needs to show correctly per the following parameters.

If the day of the week shown in column “L” is Saturday, Sunday, or Monday then the date appearing in column “B” needs to be 5 days hence.

As you can see by the attached Xl2bb Mini Sheet, my formulas only have one condition, namely that L5 = “Saturday” but it gets even more confusing based on the “Day of the Week” number shown in column “I” because in rows 11 to 18 column “I” includes only numbers and as you can see the dates showing in column “B” get to be different than intended in 6 of the 7 instances.

Perhaps there are one or more columns not needed.

Any help will be much appreciated.

Cell Formulas
RangeFormula
B12:B18,B5:B8B5=IF(L5="Saturday",H5+5,K5)
C12:C18,C5:C8C5=TEXT(D5,"mmm/dd/yyyy ")&TEXT(E5,"hh:mm:ss")
D12:D18,D5:D8D5=H5
K12:K18,K5:K8K5=SUM($H5+$I5)
L12:L18,L5:L8L5=TEXT(K5,"dddd")
I5:I8I5=WEEKDAY(H5,2)
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If you are trying to skip non workdays (weekends for example) you can use the WorkDay.INTL function. Not sure if it is avaliable in Excl 2013, though.
 
Upvote 0
something like what is in column A below:

mr excel questions 12.xlsm
ABCDEFGHIJKL
2Order Delivery Date Pick Order Date DateTimeActual Pick Order Date Day of the Week
3
4
5Fri 2023-01-13Mon 2023-01-09 00:00Jan/05/2023 10:22:00Thu 2023-01-05 00:0010:22:00Thu 2023-01-05 00:004Mon 2023-01-09 00:00Monday
6Thu 2023-02-16Mon 2023-02-13 00:00Feb/08/2023 14:23:00Wed 2023-02-08 00:0014:23:00Wed 2023-02-08 00:003Sat 2023-02-11 00:00Saturday
7Tue 2023-03-14Wed 2023-03-08 00:00Mar/03/2023 14:55:00Fri 2023-03-03 00:0014:55:00Fri 2023-03-03 00:005Wed 2023-03-08 00:00Wednesday
8Thu 2023-04-13Mon 2023-04-10 00:00Apr/05/2023 00:00:00Wed 2023-04-05 00:00Wed 2023-04-05 00:003Sat 2023-04-08 00:00Saturday
9
10
11Day of the Week Number Testing Such That the Numbers shown in I12:I18 are Actual Numbers
12Fri 2023-01-13Fri 2023-01-06 00:00Jan/05/2023 10:22:00Thu 2023-01-05 00:0010:22:00Thu 2023-01-05 00:001Fri 2023-01-06 00:00Friday
13Thu 2023-02-16Fri 2023-02-10 00:00Feb/08/2023 14:23:00Wed 2023-02-08 00:0014:23:00Wed 2023-02-08 00:002Fri 2023-02-10 00:00Friday
14Tue 2023-03-14Mon 2023-03-06 00:00Mar/03/2023 14:55:00Fri 2023-03-03 00:0014:55:00Fri 2023-03-03 00:003Mon 2023-03-06 00:00Monday
15Thu 2023-04-13Sun 2023-04-09 00:00Apr/05/2023 00:00:00Wed 2023-04-05 00:00Wed 2023-04-05 00:004Sun 2023-04-09 00:00Sunday
16Fri 2023-01-13Tue 2023-01-10 00:00Jan/05/2023 10:22:00Thu 2023-01-05 00:0010:22:00Thu 2023-01-05 00:005Tue 2023-01-10 00:00Tuesday
17Thu 2023-02-16Tue 2023-02-14 00:00Feb/08/2023 14:23:00Wed 2023-02-08 00:0014:23:00Wed 2023-02-08 00:006Tue 2023-02-14 00:00Tuesday
18Tue 2023-03-14Fri 2023-03-10 00:00Mar/03/2023 14:55:00Fri 2023-03-03 00:0014:55:00Fri 2023-03-03 00:007Fri 2023-03-10 00:00Friday
Sheet26
Cell Formulas
RangeFormula
A5:A8,A12:A18A5=WORKDAY.INTL(H5,5,"1000011")
B5:B8,B12:B18B5=IF(L5="Saturday",H5+5,K5)
C5:C8,C12:C18C5=TEXT(D5,"mmm/dd/yyyy ")&TEXT(E5,"hh:mm:ss")
D5:D8,D12:D18D5=H5
K5:K8,K12:K18K5=SUM($H5+$I5)
L5:L8,L12:L18L5=TEXT(K5,"dddd")
I5:I8I5=WEEKDAY(H5,2)
 
Upvote 0
This is heading in a better direction but something is still amiss. I changed the value from 5 down to 2. This fixed the first 3 dates but notice the 4th date should be April 8 but turned into April 7.
So not sure why but using the number 5 in the formula gets it way off.

Bogus OrderPickDate.xlsx
CDEFGHIJ
2Order Delivery Date Pick Order Date DateTimeActual Pick Order Date Day of the Week
3
4
5January 10, 2023Jan/05/2023 10:22:00January 05, 202310:22:00January 05, 20234
6February 10, 2023Feb/08/2023 14:23:00February 08, 202314:23:00February 08, 20233
7March 08, 2023Mar/03/2023 14:55:00March 03, 202314:55:00March 03, 20235
8April 07, 2023Apr/05/2023 00:00:00April 05, 2023April 05, 20233
Orders
Cell Formulas
RangeFormula
C5:C8C5=WORKDAY.INTL(I5,2,"1000011")
D5:D8D5=TEXT(E5,"mmm/dd/yyyy ")&TEXT(F5,"hh:mm:ss")
E5:E8E5=I5
J5:J8J5=WEEKDAY(I5,2)
 
Upvote 0
Do the actual number of workdays for the delivery vary depending on the day of the week? The formula I gave advanced 5 workdays, skipping over Sat, Sun, Mon.
What is amiss?. I cannot tell. And for ease of me understanding can you add the weekday to the formatting of the cells that are being calcuated, as I have done.
 
Upvote 0
you wrote:

"If the day of the week shown in column “L” is Saturday, Sunday, or Monday then the date appearing in column “B” needs to be 5 days hence."

What is the calcuation for column B if L has Tues, Wed, Thur, or Fri?
if 2 days then use this:
Excel Formula:
=WORKDAY.INTL(H5,2,"1000011")
 
Upvote 0
Is this what you want?
Excel Formula:
=IF(WEEKDAY(K5,12)>4,H5+5,K5)
 
Upvote 0
Okay, I think I see an issue with why this isn’t working well. The number of days between the actual order date and the delivery date is always 3 working days.
So if an order is placed on Wednesday, Thursday, or Friday then it follows that an order placed on Wednesday would not be delivered until the following Monday, an order placed on Thursday would not be delivered until the following Tuesday and an order placed on Friday would not be delivered until the following Wednesday.
Saturdays and Sundays are always omitted in the 3-day count as they are not working days for the company the orders are placed with.
Three examples follow:
Order placed on Wednesday:
Thursday is one working day, Friday is the second working day, and Monday is the third working day and is also the day of delivery, always 3 days.
Order placed on Thursday:
Friday is one working day, Monday is the second working day, and Tuesday is the third working day and is also the day of delivery, always 3 days.
Order placed on Friday:
Monday is the first working day, Tuesday is the second working day, and Wednesday is the third working day and is also the day of delivery, always 3 days.

Bogus OrderPickDate.xlsx
BCDEFGHIJKLM
2Actual Delivery DatesOrder Delivery Date Per workday.intl formulaPick Order Date DateTimeActual Pick Order Date Day of the Week
3
4
5January 10, 2023January 10, 2023Jan/05/2023 10:22:00January 05, 202310:22:00January 05, 20234January 09, 2023Monday
6February 13, 2023February 10, 2023Feb/08/2023 14:23:00February 08, 202314:23:00February 08, 20233February 11, 2023Saturday
7March 08, 2023March 08, 2023Mar/03/2023 14:55:00March 03, 202314:55:00March 03, 20235March 08, 2023Wednesday
8April 10, 2023April 07, 2023Apr/05/2023 00:00:00April 05, 2023April 05, 20233April 08, 2023Saturday
Orders
Cell Formulas
RangeFormula
C5:C8C5=WORKDAY.INTL(I5,2,"1000011")
D5:D8D5=TEXT(E5,"mmm/dd/yyyy ")&TEXT(F5,"hh:mm:ss")
E5:E8E5=I5
L5:L8L5=SUM($I5+$J5)
M5:M8M5=TEXT(L5,"dddd")
J5:J8J5=WEEKDAY(I5,2)
 
Upvote 0
so, you should be good to go with:
Excel Formula:
=WORKDAY.INTL(I5,3,"0000011")
 
Upvote 0
and if you have holidays to be concerned with, those can be incorporated into a fourth argument.

 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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