Conditional Formatting

JamieP89

Board Regular
Joined
Mar 8, 2022
Messages
64
Office Version
  1. 365
Platform
  1. Windows
Morning All,

I wonder if I can ask for some guidance on whether there is a way to track say the last 7 days using TODAY within conditional formatting?

I'm looking for something like =A:A=MAX(TODAY()-7)

Needless to say the above isn't working for me. But Not sure what I'm doing wrong? (Assume A:A is the range of data I am looking for the max with) and not any date ranges. Wondering If because I haven't selected any dates to track that's the issues?

Hope this makes sense?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
If this is not what you mean, please supply some sample data with XL2BB and explain in relation to your sample data exactly what should be highlighted and why.

22 09 20.xlsm
A
125/09/2022
219/09/2022
325/09/2022
427/09/2022
51/10/2022
615/09/2022
719/09/2022
823/09/2022
926/09/2022
103/10/2022
1113/09/2022
1212/09/2022
1321/09/2022
142/10/2022
1524/09/2022
1622/09/2022
1716/09/2022
1828/09/2022
1926/09/2022
202/10/2022
Last 7 Days
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:A20Expression=A1=MEDIAN(A1,TODAY(),TODAY()-7)textNO
 
Upvote 0
Sorry for the delay in coming back I've been unwell!

Here's some data mocked up for demonstration purposes. So lets say I currently have the last 7 days being tracked (assuming its the 7th Sept today) - What I would like to be able to do, is conditionally format so that the highest and lowest number for the current rolling 7 days is just automatically tracking instead of having to shift the range for the conditional format each day.

So Tomorrow (F17 - 8th Sept for these purposes) would now be in range, and F10 (1st) would be dropped. Just finding it hassle to have to change every day (not to mention there's margin for error in forgetting!)

Numbers
01-Sep-2288
02-Sep-2282
03-Sep-2226
04-Sep-2211
05-Sep-2215
06-Sep-229
07-Sep-226
08-Sep-22
09-Sep-22
10-Sep-22
11-Sep-22
12-Sep-22
13-Sep-22
14-Sep-22
15-Sep-22
16-Sep-22
17-Sep-22
18-Sep-22
19-Sep-22
20-Sep-22
21-Sep-22
22-Sep-22
23-Sep-22
24-Sep-22
25-Sep-22
26-Sep-22
27-Sep-22
28-Sep-22
29-Sep-22
30-Sep-22
01-Oct-22
 
Upvote 0
It's 23 September here at the moment

22 09 23.xlsm
AB
1Numbers
21-Sep-2288
32-Sep-2282
43-Sep-2226
54-Sep-2211
65-Sep-2215
76-Sep-229
87-Sep-226
98-Sep-22
109-Sep-22
1110-Sep-22
1211-Sep-22
1312-Sep-22
1413-Sep-22
1514-Sep-22
1615-Sep-22
1716-Sep-22
1817-Sep-22
1918-Sep-22
2019-Sep-22
2120-Sep-22
2221-Sep-22
2322-Sep-22
2423-Sep-22
2524-Sep-22
2625-Sep-22
2726-Sep-22
2827-Sep-22
2928-Sep-22
3029-Sep-22
3130-Sep-22
321-Oct-22
CF Week
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B32Expression=A2=TODAY()-6textNO
B2:B32Expression=A2=TODAY()textNO
 
Upvote 0
It's 23 September here at the moment

22 09 23.xlsm
AB
1Numbers
21-Sep-2288
32-Sep-2282
43-Sep-2226
54-Sep-2211
65-Sep-2215
76-Sep-229
87-Sep-226
98-Sep-22
109-Sep-22
1110-Sep-22
1211-Sep-22
1312-Sep-22
1413-Sep-22
1514-Sep-22
1615-Sep-22
1716-Sep-22
1817-Sep-22
1918-Sep-22
2019-Sep-22
2120-Sep-22
2221-Sep-22
2322-Sep-22
2423-Sep-22
2524-Sep-22
2625-Sep-22
2726-Sep-22
2827-Sep-22
2928-Sep-22
3029-Sep-22
3130-Sep-22
321-Oct-22
CF Week
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B32Expression=A2=TODAY()-6textNO
B2:B32Expression=A2=TODAY()textNO

Thank you - But I'm not sure this answers my original question. I am looking for the conditional format to highlight the min and max values over the last 7 days so green would be high, red low. and only show that on the last 7 days.

Appreciate it's the 22nd (i'm not overly worried about that as this is just for demonstration purposes here) but for full completeness then. Here's data for the entire month up to todays date. Can we write something that allows the conditional format to

1) Only track the last 7 days
2) Highlight max value over the last 7 days in green
3) highlight min value over the last 7 days in red

Essentially when I log in tomorrow to the 24th (23rd today) to a blank cell, I want to be able to fill that blank in, in the knowledge that the conditional format is already tracking the last 7 days based on TODAY (being the day I would be on)

Numbers
01-Sep-229
02-Sep-2227
03-Sep-2243
04-Sep-2220
05-Sep-2227
06-Sep-2257
07-Sep-2215
08-Sep-2273
09-Sep-2217
10-Sep-2244
11-Sep-2256
12-Sep-2213
13-Sep-2214
14-Sep-2253
15-Sep-2273
16-Sep-2291
17-Sep-2225
18-Sep-2294
19-Sep-2272
20-Sep-2289
21-Sep-2234
22-Sep-2222
23-Sep-2227
24-Sep-22
25-Sep-22
26-Sep-22
27-Sep-22
28-Sep-22
29-Sep-22
30-Sep-22
01-Oct-22
 
Upvote 0
:oops: Sorry, I thought that you were referring to the dates.

Try this instead

22 09 23.xlsm
AB
1Numbers
21-Sep-2288
32-Sep-2282
43-Sep-2226
54-Sep-2211
65-Sep-2215
76-Sep-229
87-Sep-226
98-Sep-2288
109-Sep-2282
1110-Sep-2288
1211-Sep-2282
1312-Sep-2226
1413-Sep-2211
1514-Sep-2215
1615-Sep-229
1716-Sep-226
1817-Sep-2288
1918-Sep-2282
2019-Sep-2226
2120-Sep-2211
2221-Sep-2215
2322-Sep-229
2423-Sep-226
2524-Sep-2288
2625-Sep-2282
2726-Sep-2226
2827-Sep-2211
2928-Sep-2215
3029-Sep-229
3130-Sep-226
321-Oct-22
CF Week
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B32Expression=AND(A2<=TODAY(),A2>TODAY()-7,B2=MAXIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7))textNO
B2:B32Expression=AND(A2<=TODAY(),A2>TODAY()-7,B2=MINIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7))textNO
 
Upvote 0
Solution
:oops: Sorry, I thought that you were referring to the dates.

Try this instead

22 09 23.xlsm
AB
1Numbers
21-Sep-2288
32-Sep-2282
43-Sep-2226
54-Sep-2211
65-Sep-2215
76-Sep-229
87-Sep-226
98-Sep-2288
109-Sep-2282
1110-Sep-2288
1211-Sep-2282
1312-Sep-2226
1413-Sep-2211
1514-Sep-2215
1615-Sep-229
1716-Sep-226
1817-Sep-2288
1918-Sep-2282
2019-Sep-2226
2120-Sep-2211
2221-Sep-2215
2322-Sep-229
2423-Sep-226
2524-Sep-2288
2625-Sep-2282
2726-Sep-2226
2827-Sep-2211
2928-Sep-2215
3029-Sep-229
3130-Sep-226
321-Oct-22
CF Week
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B32Expression=AND(A2<=TODAY(),A2>TODAY()-7,B2=MAXIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7))textNO
B2:B32Expression=AND(A2<=TODAY(),A2>TODAY()-7,B2=MINIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7))textNO
This worked a treat - Just wish I could fully understand all of it :(
 
Upvote 0
Glad it worked for you. Thanks for letting us know. (y)
 
Upvote 0
Glad it worked for you. Thanks for letting us know. (y)
Hope you don't mind me reopening this to ask, but I'm trying to understand the importance of AND and how this is used within the overall formula? I've read up and understand this is for checking whether more than one piece of logic is TRUE or if not FALSE, but can't understand why that would be important?

Also, while I am asking

Why do we write the remaining piece of the formula as below? Sorry, my need to understand everything about this is too much to leave alone and just accept it works :)

B2=MAXIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7))
 
Upvote 0
Hope you don't mind me reopening this to ask,
Not at all. It is good that you are trying to 'understand', rather than just 'use'. :)
I'll do the best I can to explain, by looking at the green (max) condition

Let's start at the end
B2=MAXIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7)

The amber part calculates the maximum value in column B for dates in the last week (88). So, to be green a cell in column B must contain 88. However, as you can see, there are five 88 values in column B so being 88 is not enough by itself. We have to find the particular 88 (or there could be more than one of them) that has a date in the last week. Excel does not have a function for "the last week" so we get to the final result by saying that to be green ..
  • the column B value must be the greatest value in the last week (88), AND
  • the date in column A must be today's date or less, AND
  • the date in column A must be greater than 7 days ago
Those last two points together create the "in the last week" condition.

Our formula has those three conditions but just in a different order, and the syntax is that the AND goes out the front rather than between each condition
=AND(A2<=TODAY(),A2>TODAY()-7,B2=MAXIFS(B$2:B$32,A$2:A$32,"<="&TODAY(),A$2:A$32,">"&TODAY()-7))

I hope that helps. :)
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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