Conditional formatting dates

ThedoreHolley

Board Regular
Joined
Sep 26, 2016
Messages
51
Office Version
  1. 365
Platform
  1. Windows
I am trying to conditional format a column that has dates. (D-mmm-yy).
I want to highlight dates that are 18 months -23 months amber. And anything 24 or older red.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
are they real dates
any way
conditional formatting rule

Assuming dates in column a row 2
in this order and stop if true
=AND(A2<>"",A2<DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
format red

2nd rule
=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())))
format yellow

Cell Formulas
RangeFormula
A3:A28A3=A2-50
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A32Expression=AND(A2<>"",A2<DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))textYES
A2:A29Expression=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())))textYES



A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
Here is the data I am using. I used the formula send, but as you can see it's all amber.
 

Attachments

  • 1000004818.jpg
    1000004818.jpg
    195 KB · Views: 9
Upvote 0
ok, did you put them in the same order
and stop of true
 

Attachments

  • Screenshot 2024-02-07 at 20.20.31.png
    Screenshot 2024-02-07 at 20.20.31.png
    151.5 KB · Views: 11
Upvote 0
I did them in order and as soon as apply the 2nd rule it is overriding the 1st.
 
Upvote 0
and red one first

for amber rule you could use this
=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())), A2>=DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
so that it does not return TRUE for 2 years dates

as you cna see in column C - it will also be amber in the RED zone - hence why red is first and stop if true
column F has the new rule inof

C,D & F are not used - just for information

you may need an = or not depending on what you want to do if exactly 2 years or 18months - RED or YELLOW

I have added to a share - so you can open the spreadsheet

will only be on dropbox for a few days


Cell Formulas
RangeFormula
C2:C28C2=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())))
D2:D28D2=AND(A2<>"",A2<DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
A3:A28A3=A2-50
F2:F28F2=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())), A2>DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A32Expression=AND(A2<>"",A2<DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))textYES
A2:A29Expression=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())))textYES
 
Upvote 0
and red one first

for amber rule you could use this
=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())), A2>=DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
so that it does not return TRUE for 2 years dates

as you cna see in column C - it will also be amber in the RED zone - hence why red is first and stop if true
column F has the new rule inof

C,D & F are not used - just for information

you may need an = or not depending on what you want to do if exactly 2 years or 18months - RED or YELLOW

I have added to a share - so you can open the spreadsheet

will only be on dropbox for a few days


Cell Formulas
RangeFormula
C2:C28C2=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())))
D2:D28D2=AND(A2<>"",A2<DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
A3:A28A3=A2-50
F2:F28F2=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())), A2>DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A32Expression=AND(A2<>"",A2<DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())))textYES
A2:A29Expression=AND(A2<>"",A2<DATE(YEAR(TODAY()),MONTH(TODAY())-18,DAY(TODAY())))textYES
Does it have with my date format is 1- May-22. d-mmm-yy
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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