Conditional Formatting - Everyones Bane

KyleG

Well-known Member
Joined
Jun 12, 2004
Messages
629
Office Version
  1. 365
Platform
  1. Windows
I thought what i wanted would be simple but no matter how i do it i cant seem to get it to work.

I have a column (B) of times in the format [h:mm]. I want to hightlight non-normal hours.

Normal hours are 7:00 - 8:00 Monday to Friday. (Days listed in column A)
eg:
10:00 Monday - cell formatted.
No value Monday - cell formatted
No value Saturday - cell stays as normal
Any hours Saturday - cell formatted

thanks
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this for your conditional formatting formula:

PHP:
=OR(B1<TIMEVALUE("7:00"),B1>TIMEVALUE("8:00"),A1="Saturday",A1="Sunday")

With Weekday in A1, and your time in B1.

------
Forum posting problem:
Had to wrap my formula with PHP Code tags to get it to display properly, the ordinary CODE tags didn't do the trick. It removed everything between < and > in the formula.....
 
Last edited:
Upvote 0
I see that I missed the part about blank time cells on weekends should stay unformatted. Try this formula instead, to take care of this:
PHP:
=IF(OR(A1="Saturday",A1="Sunday"),B1,OR(B1<TIMEVALUE("7:00"),B1>TIMEVALUE("8:00")))
 
Upvote 0
Awesome thanks.

Made an alteration because i didnt give you the full details, re the date in the A column is a day, its a full date. Also the first 3 rows contained merged cells which appear to be causing hickups. These work perfect for the B and C row respectively


=IF(OR(WEEKDAY(A4)=1,WEEKDAY(A4)=7),B4, OR(B4<TIMEVALUE("7:00"),B4>TIMEVALUE("8:00")))
Edit:The above line is not posting correctly it contains the part of the original code you provided wit the 7am time.

=IF(OR(WEEKDAY(A4)=1,WEEKDAY(A4)=7),C4,C4<>TIMEVALUE("17:30"))

However now im trying to be really difficult and make it so that if the B or the C cell meets the conditional format the other one will also even if either meets its own criteria.

Sorry to be a pain.
 
Last edited:
Upvote 0
=if(or(weekday(a4)=1,weekday(a4)=7),b4,or(b4< Timevalue("7:00"),b4>timevalue("8:00")))
 
Upvote 0
You seem to be checking for 7AM-8AM is this correct, or is it 7AM - 8 PM?
 
Upvote 0
Assuming you mean 7AM-8PM, perhaps:

=OR(AND($A4<>"",WEEKDAY($A4,2)>5),AND(COUNT($B4:$C4),COUNTIF($B4:$C4,"<07:00")+COUNTIF($B4:$C4,">20:00")))
 
Upvote 0
Roster.xls
ABCD
172Mon,7 Jan7:3017:301:00
173Tue,8 Jan7:3017:301:00
174Wed,9 Jan11:4521:000:30
175Thu,10 Jan7:3017:300:45
176Fri,11 Jan8:0017:451:00
177Sat,12 Jan
178Sun,13 Jan
179Mon,14 Jan7:0017:451:00
180Tue,15 Jan7:0017:301:00
181Wed,16 Jan7:3017:301:00
182Thu,17 Jan7:3017:301:00
183Fri,18 Jan
184Sat,19 Jan7:3012:30
185Sun,20 Jan7:309:00
186Mon,21 Jan7:0017:301:00
187Tue,22 Jan8:0017:301:00
188Wed,23 Jan7:3017:301:00
189Thu,24 Jan7:3017:301:00
190Fri,25 Jan
191Sat,26 Jan7:3017:301:00
192Sun,27 Jan7:3012:30
Roster



8am is correct the B column represents start time and the C finish time. I cant get your formula to work so heres more information.

In the B column i have the conditional format formula
=if(or(weekday(a4)=1,weekday(a4)=7),b4,or(b4< Timevalue("7:00"),b4 >timevalue("8:00")))

In the C column i have the conditional format formula
=IF(OR(WEEKDAY(A4)=1,WEEKDAY(A4)=7),C4,C4<>TIMEVALUE("17:30"))

these work fine but where the B column conditional format kicks in i want the c column conditional format to kick in also. eg. Fri 11th conditional format would kick in for Finish time but the star time is ok so no conditional format. But because the Finish time format applies the start time should also apply. and the opposite should apply if true.
 
Upvote 0
Try to use this Conditional Formatting formula entered in b4, copy format to c4 and down column b and c.

PHP:
=if(or(weekday($a4)=1,weekday($a4)=7),$b4+$c4,or($b4< Timevalue("7:00"),$b4 >timevalue("8:00"),$c4<>TIMEVALUE("17:30")))
 
Upvote 0
Thanks Bjornar thats exactly what i was after.
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,716
Members
451,665
Latest member
PierreF

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