Need help with conditional formatting.

duskwood47

New Member
Joined
Oct 9, 2017
Messages
28
Is it possible to create conditional formatting for a single cell based on what value is in the cell but also taking into consideration what day of the week it is.

For example - Mon through Thursday if cell value less than 85, then cell color red, if greater than 85 then cell color green, however if Friday, then if cell value is less than 104, cell color red, cell value greater than 104, cell value green?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
you can use Weekday() for the day of the week , with an AND or OR

I assume Sat & Sun would be unformatted

What cell is the date in ?

What colour if the cell is equal to 85 or 104 ?

A blank cell is seen as zero , so if the value is blank should that be coloured

Something like

RED
Mon through Thursday if cell value less than 85, then cell color red,
if Friday, then if cell value is less than 104, cell color red,
OR( AND ( Weekday ( cell with date , 2) < 5 , Cell with value in <85 ) , AND(Weekday ( cell with date , 2) = 5 , Cell with value in < 104) )

GREEN
if greater than 85 then cell color green,
cell value greater than 104, cell value green?

OR( AND ( Weekday ( cell with date , 2) < 5 , Cell with value in > 85 ) , AND(Weekday ( cell with date , 2) = 5 , Cell with value in > 104) )


example data set.xlsx
ABCDE
1WeekdayValueREDGREEN
21/1/21FridayTRUEFALSE
31/2/21SaturdayFALSEFALSE
41/3/21SundayFALSEFALSE
51/4/2150MondayTRUEFALSE
61/5/21100TuesdayFALSETRUE
71/6/2140WednesdayTRUEFALSE
81/7/2133ThursdayTRUEFALSE
91/8/21100FridayTRUEFALSE
101/9/21SaturdayFALSEFALSE
111/10/21SundayFALSEFALSE
121/11/2150MondayTRUEFALSE
131/12/21100TuesdayFALSETRUE
141/13/2140WednesdayTRUEFALSE
151/14/2133ThursdayTRUEFALSE
161/15/21100FridayTRUEFALSE
171/16/2150SaturdayFALSEFALSE
181/17/21100SundayFALSEFALSE
191/18/2140MondayTRUEFALSE
201/19/2133TuesdayTRUEFALSE
211/20/21100WednesdayFALSETRUE
221/21/21ThursdayTRUEFALSE
231/22/21FridayTRUEFALSE
Sheet2
Cell Formulas
RangeFormula
C2:C23C2=A2
D2:D23D2=OR(AND(WEEKDAY(A2,2)<5,B2<85),AND(WEEKDAY(A2,2)=5,B2<104))
E2:E23E2=OR(AND(WEEKDAY(A2,2)<5,B2>85),AND(WEEKDAY(A2,2)=5,B2>104))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B23Expression=OR(AND(WEEKDAY(A2,2)<5,B2>85),AND(WEEKDAY(A2,2)=5,B2>104))textNO
B2:B23Expression=OR(AND(WEEKDAY(A2,2)<5,B2<85),AND(WEEKDAY(A2,2)=5,B2<104))textNO
 
Last edited:
Upvote 0
you can use Weekday() for the day of the week , with an AND or OR

I assume Sat & Sun would be unformatted

What cell is the date in ?

What colour if the cell is equal to 85 or 104 ?

Something like

RED
Mon through Thursday if cell value less than 85, then cell color red,
if Friday, then if cell value is less than 104, cell color red,
OR( AND ( Weekday ( cell with date , 2) < 5 , Cell with value in <85 ) , AND(Weekday ( cell with date , 2) = 5 , Cell with value in < 104) )

GREEN
if greater than 85 then cell color green,
cell value greater than 104, cell value green?

OR( AND ( Weekday ( cell with date , 2) < 5 , Cell with value in > 85 ) , AND(Weekday ( cell with date , 2) = 5 , Cell with value in > 104) )
I have an =today() in cell G1.

The cell requiring the color formatting is in cell B2.

if the cell is equal to 85 or 104 then still red.

Correct, Sat and Sun would be unformatted
 
Upvote 0
so are you just just colouring the cells based on today's day of week ?
did you want to use G1 or just include today() in the conditional formatting formula

So this is with today() in formula

OR you can change today() to use $G$1

GREEN
=OR(AND(WEEKDAY(TODAY(),2)<5,B2>85),AND(WEEKDAY(TODAY(),2)=5,B2>104))

RED
=OR(AND(WEEKDAY(TODAY(),2)<5,B2<=85),AND(WEEKDAY(TODAY(),2)=5,B2<=104))


example data set.xlsx
B
2104
3105
485
550
6100
740
833
9200
10
11
1250
13400
1440
1533
16100
17500
18100
1940
2033
21100
22
23
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B23Expression=OR(AND(WEEKDAY(TODAY(),2)<5,B2>85),AND(WEEKDAY(TODAY(),2)=5,B2>104))textNO
B2:B23Expression=OR(AND(WEEKDAY(TODAY(),2)<5,B2<=85),AND(WEEKDAY(TODAY(),2)=5,B2<=104))textNO
 
Upvote 0
Solution
so are you just just colouring the cells based on today's day of week ?
did you want to use G1 or just include today() in the conditional formatting formula

So this is with today() in formula

OR you can change today() to use $G$1

GREEN
=OR(AND(WEEKDAY(TODAY(),2)<5,B2>85),AND(WEEKDAY(TODAY(),2)=5,B2>104))

RED
=OR(AND(WEEKDAY(TODAY(),2)<5,B2<=85),AND(WEEKDAY(TODAY(),2)=5,B2<=104))


example data set.xlsx
B
2104
3105
485
550
6100
740
833
9200
10
11
1250
13400
1440
1533
16100
17500
18100
1940
2033
21100
22
23
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B23Expression=OR(AND(WEEKDAY(TODAY(),2)<5,B2>85),AND(WEEKDAY(TODAY(),2)=5,B2>104))textNO
B2:B23Expression=OR(AND(WEEKDAY(TODAY(),2)<5,B2<=85),AND(WEEKDAY(TODAY(),2)=5,B2<=104))textNO
No. I am changing it based on the value in the cell which is dynamically changing based on a vba counter i built. However the requirement for our "goal" depends on what day it is. So Monday through thursday, our goal is 85, friday its 103.

1634333193996.png
 
Upvote 0
our goal is 85, friday its 103.

on Mon-Thur - Red = 85
on Fri - Red = 104

if you want to use G1 then

GREEN
=OR(AND(WEEKDAY($G$1,2)<5,B2>85),AND(WEEKDAY($G$1,2)=5,B2>104))

RED
=OR(AND(WEEKDAY($G$1,2)<5,B2<=85),AND(WEEKDAY($G$1,2)=5,B2<=104))

 
Upvote 0
Thanks for the help. Looks like it worked. Appreciate it. Ill know for sure when I hit 104 for the day today :)
 
Upvote 0
ok, i'm in uk, so signing off soon
you are welcome
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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