Conditional Formatting Date Ranges

LeighMacKay7

New Member
Joined
Oct 11, 2022
Messages
34
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Web
Hi all,
I am hoping you can help me.

I have a number of dates displayed dd/mm/yyyy hh:mm, which I need to add some conditional formatting too the column.

What I would like, is a formula which includes =TODAY() and helps me with the following.

> Between todays date and 5 months ago = GREEN text
> Greater than 5 months ago and less than and equal to 6 months = AMBER text
> Greater than 6 months = RED text.
There is also a 4th option, which is text based and says "No Staff Information Form", which would need to be displayed in another colour text (maybe purple?)

I have messed about in Conditional Formatting and have had no joy.
New Formatting Rule > Use a formula to determine which cells to format.=DATEDIF(TODAY(),T2:T1000,”m”)<=5



I have watched a couple of videos but have been unsuccesful.

Any help/pointers would be greatly received.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
A few things when writing Conditional Formatting Rules.

1. Do not use slanted double-quotes in your formula, i.e.
”m”
should be:
"m"

2. When writing the formula, select the range you want to apply the rule to, and then write the rule as it applies to the single activecell (usually the first cell in your selected range). Excel will adjust it automatically for all the other cells. So if you have selected rows 2 down to 1000, you should write the formula like:
=DATEDIF(TODAY(),$T2,"m")<=5
 
Upvote 0
A few things when writing Conditional Formatting Rules.

1. Do not use slanted double-quotes in your formula, i.e.
”m”
should be:
"m"

2. When writing the formula, select the range you want to apply the rule to, and then write the rule as it applies to the single activecell (usually the first cell in your selected range). Excel will adjust it automatically for all the other cells. So if you have selected rows 2 down to 1000, you should write the formula like:
=DATEDIF(TODAY(),$T2,"m")<=5
Thank you Joe4.
Much appreciated.

I think I am making progress with EDATE.

I just need the Amber text to display Greater than 5 months ago and less than and equal to 6 months and then Green Text to display between todays date and 5 months ago

1707764889479.png
 
Upvote 0
You can use AND to combine two conditions in one (to do a "between" two values), i.e.
=AND(T2>some calc, T2<some calc)
 
Upvote 0
I understand the value of < and > . however, I am not sure how I work this with dates which are constantly moving from Todays date.
 
Upvote 0
I understand the value of < and > . however, I am not sure how I work this with dates which are constantly moving from Todays date.
I am not sure I follow what you are saying. Using the TODAY function in your formulas/calculations, like you did in your posts takes care of that. It makes your formulas dynamic.
So what precisely is still tripping you up?
 
Upvote 0
Sorry, I am not following.

Basically, what I am saying is. I don't know what formula's to use. For both Amber (Between 5 months and 6 months) and then anything less than 5 months.

Which I have circled in red in the screenshot above.
 
Upvote 0
It is just like I said.

Amber:
Excel Formula:
=AND(T2>EDATE(TODAY(),-6),T2<EDATE(TODAY(),-5))

Green:
Excel Formula:
=T2<EDATE(TODAY(),-6)

Note that you will need to decide what to do if it is EXACTLY 5 months or 6 months, and change some ">" to ">=" and/or "<" to "<=" where necessary.
 
Upvote 0
Solution
@LeighMacKay7 , here is a great YouTube tutorial on conditional formatting. Please take a look:



Below is what I think you asked for, although I'm changing fill and not text. It inlcudes a column checking for staff data, but not entirely sure how you calculate it:
Book1
ABCDEF
1Staff Info<=5Month<=6 &>5>6MonthNo Staff
22023-01-20YesFALSEFALSETRUEFALSE
32023-02-20noFALSEFALSETRUETRUE
42023-03-20noFALSEFALSETRUETRUE
52023-04-20noFALSEFALSETRUETRUE
62023-05-20YesFALSEFALSETRUEFALSE
72023-06-20YesFALSEFALSETRUEFALSE
82023-07-20YesFALSEFALSETRUEFALSE
92023-08-20YesFALSETRUEFALSEFALSE
102023-09-20YesTRUEFALSEFALSEFALSE
112023-10-20YesTRUEFALSEFALSEFALSE
122023-11-20YesTRUEFALSEFALSEFALSE
132023-12-20NoTRUEFALSEFALSETRUE
142024-01-20NoTRUEFALSEFALSETRUE
152024-02-20YesTRUEFALSEFALSEFALSE
Sheet9
Cell Formulas
RangeFormula
C2:C15C2=$A2>=EDATE(TODAY(),-5)
D2:D15D2=AND($A2>=EDATE(TODAY(),-6),$A2<EDATE(TODAY(),-5))
E2:E15E2=$A2<EDATE(TODAY(),-6)
F2:F15F2=$B2="No"
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:F15Expression=$B2="No"textNO
A2:F15Expression=$A2<EDATE(TODAY(),-6)textNO
A2:F15Expression=AND($A2>=EDATE(TODAY(),-6),$A2<EDATE(TODAY(),-5))textNO
A2:F15Expression=$A2>=EDATE(TODAY(),-5)textNO
 
Upvote 0
@LeighMacKay7 , here is a great YouTube tutorial on conditional formatting. Please take a look:



Below is what I think you asked for, although I'm changing fill and not text. It inlcudes a column checking for staff data, but not entirely sure how you calculate it:
Book1
ABCDEF
1Staff Info<=5Month<=6 &>5>6MonthNo Staff
22023-01-20YesFALSEFALSETRUEFALSE
32023-02-20noFALSEFALSETRUETRUE
42023-03-20noFALSEFALSETRUETRUE
52023-04-20noFALSEFALSETRUETRUE
62023-05-20YesFALSEFALSETRUEFALSE
72023-06-20YesFALSEFALSETRUEFALSE
82023-07-20YesFALSEFALSETRUEFALSE
92023-08-20YesFALSETRUEFALSEFALSE
102023-09-20YesTRUEFALSEFALSEFALSE
112023-10-20YesTRUEFALSEFALSEFALSE
122023-11-20YesTRUEFALSEFALSEFALSE
132023-12-20NoTRUEFALSEFALSETRUE
142024-01-20NoTRUEFALSEFALSETRUE
152024-02-20YesTRUEFALSEFALSEFALSE
Sheet9
Cell Formulas
RangeFormula
C2:C15C2=$A2>=EDATE(TODAY(),-5)
D2:D15D2=AND($A2>=EDATE(TODAY(),-6),$A2<EDATE(TODAY(),-5))
E2:E15E2=$A2<EDATE(TODAY(),-6)
F2:F15F2=$B2="No"
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:F15Expression=$B2="No"textNO
A2:F15Expression=$A2<EDATE(TODAY(),-6)textNO
A2:F15Expression=AND($A2>=EDATE(TODAY(),-6),$A2<EDATE(TODAY(),-5))textNO
A2:F15Expression=$A2>=EDATE(TODAY(),-5)textNO
Thank you. This has been a great help. And has helped me achieve what I set out to do :)
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

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