IF functions with weekdays

jpneeson

New Member
Joined
Apr 20, 2012
Messages
14
Hi guys. I have a Rota sheet that I'm doing some work on. I have an if function in to retrieve the data from the master Rota for each user if they are in that day. The issues I'm having is the coloum beside it.

I want to put a formula in that says for example if b4 is not empty weekday is Monday to Friday 17:00 - 09:00

I have the weekday part worked out I just need this formula to only kick in if the previous Colum is not blank.

Thanks in advance if you can help.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This is the current formula i am using. If i try =IF(B4<>"", i get the error to say to many arguments.

=IF(WEEKDAY(A4)=2,"17:00",IF(WEEKDAY(A4)=3,"17:00",IF(WEEKDAY(A4)=4,"17:00",IF(WEEKDAY(A4)=5,"17:00",IF(WEEKDAY(A4)=6,"17:00",IF(WEEKDAY(A4)=1,"09:00",IF(WEEKDAY(A4)=7,"09:00","")))))))
 
Upvote 0
How about, IF B4 is blank then nothing else:

You have 5 scenarios for 17:00 and 2 for 09:00, change them to ORs.

There is a limit to the number of IFs you can do. 7 I believe, hence the error.

=IF(B4="","",IF(OR(WEEKDAY(A4)=2,WEEKDAY(A4)=3,WEEKDAY(A4)=4,WEEKDAY(A4)=5,WEEKDAY(A4)=6),"17:00",IF(OR(WEEKDAY(A4)=1,WEEKDAY(A4)=7),"09:00","")))

Further simplified, if blank then blank, if 2-6 then 17:00 else 09:00

=IF(B4="","",IF(OR(WEEKDAY(A4)=2,WEEKDAY(A4)=3,WEEKDAY(A4)=4,WEEKDAY(A4)=5,WEEKDAY(A4)=6),"17:00","09:00"))
 
Last edited:
Upvote 0
Also depended on your Excel versio....2010 onwards will take 64 IFs.....not that you would want to do that...:diablo:
 
Last edited:
Upvote 0
@ mrshl9898:

Further simplified:

=IF(B4="","",IF(OR(WEEKDAY(A4)=1,WEEKDAY(A4)=7),"09:00","17:00"))

Even further simplified:

=IF(B4="","",IF(OR(WEEKDAY(A4)={1,7}),"09:00","17:00"))

etc.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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