Conditional Formatting Dates including Dates Passed

All_At_Sea

New Member
Joined
Aug 25, 2024
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm hoping someone could point me in the right direction on Conditional Formatting of Dates?

I've found a solution from searching the forum that suits my needs, although I'd like to add one additional condition. This is where I'm coming unstuck.

This is what I've used: -

Book1.xlsx
ABCD
1courseClaireSoorajPaula
2Autism eLearning1/2/2024No ExpiryNo Expiry
3CarePlanningF2Ftraining11/21/2023
4CareforOlderAdults1/31/2024No ExpiryNo Expiry
5Dysphagia training1/17/20241/17/20248/6/2024
6Team building3/27/20243/27/20248/17/2023
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:D6Expression=AND(B2-TODAY()<=30,B2-TODAY()>0)textNO
B2:D6Expression=AND(B2-TODAY()<=90,B2-TODAY()>30)textNO
B2:D6Expression=AND(B2-TODAY()<=365,B2-TODAY()>90)textNO


Book1.xlsx
ABCD
1period (days) =30
2
3courseClaireSoorajPaula
4Autism eLearning1/2/2024No ExpiryNo Expiry
5CarePlanningF2Ftraining11/21/2023
6CareforOlderAdults1/31/2024No ExpiryNo Expiry
7Dysphagia training1/17/20241/17/20248/6/2024
8Team building3/27/20243/27/20248/17/2023
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4:D8Expression= IF(AND($B$1>0,$B$1<=30),AND(B4-TODAY()<=30,B4-TODAY()>0))textNO
B4:D8Expression= IF(AND($B$1>30,$B$1<=90),AND(B4-TODAY()<=90,B4-TODAY()>30))textNO
B4:D8Expression= IF(AND($B$1>90,$B$1<=365),AND(B4-TODAY()<=365,B4-TODAY()>90))textNO

What I'd like to add is if the date is todays or has passed highlight it red.

I've tried adding: -

Excel Formula:
=AND(D6-TODAY()<=7)

But this causes all blank cells in my range to be coloured and not the one(s) with todays date or passed ones.

I feel I'm going around in circles, so any assistance would be gratefully received.

Thanks in advance.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
The formula you showed uses AND but only has one argument. So AND is superfluous.

Your condition checks to see if the date in D6 is earlier than 7 or more days in the future. That is in the past, or in the next 7 days.

A blank cell will be interpreted as 0, which is a date in the past, so that's why blank cells are being filled.

To check for dates today or in the past:
Excel Formula:
=AND(D6<>"",D6<=TODAY())

If the range for this rule overlaps the ranges for the rules you already have, you will have to determine which ones take precedence and then put them in the appropriate order.

I'm not sure D6 is the correct reference here because your data and other rules start in row 4. It should probably be D4.
 
Upvote 0
Many thanks for the reply @6StringJazzer appreciate it!

Fully understand your explanation and my error.

Using what you provided has worked, with one exception, but that's only after having knocked up the sheet a little further.

WSE Test.xlsx
ABCDEFGHIJKLM
1
225/08/2024
3
4ItemMOPDate DueNotes
5Liferafts3
6
7Seacrewsaver1
8
9HDJL MK511-1011-2526-3435-4041-5051-6363-7374-75
1009/10/202401/02/202523/11/202419/09/202423/09/202408/01/202508/01/202522/11/2024
11JON BUOY117/11/2024
12RELJ117/01/202504/09/2024
13OOSS525/10/2024
14Jasons Cradle426/07/2025
15GSLJ MK4105 04 DK03 02 DK01 DK1 DKEMFEmergency BoxesPilot Cabin
1615/02/202509/02/202514/09/202427/01/202505/01/202523/08/202413/02/2025
17COSALT106 05 04 DK03 02 DK01 1 DKMCR EMFAircrew RoomBridge MCREmergency BoxesHospitalChild
1819/01/202525/10/202418/02/202507/11/202426/10/202426/10/202403/11/202403/11/202402/12/2024
19MRS317/11/2024
Sheet2
Cell Formulas
RangeFormula
A2A2=TODAY()
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C6:K19Expression=AND(C6<>"",C6<=TODAY())textNO
C6:K19Expression=AND(C6-TODAY()<=30,C6-TODAY()>0)textNO
C6:K19Expression=AND(C6-TODAY()<=90,C6-TODAY()>30)textNO
C6:K19Expression=AND(C6-TODAY()<=365,C6-TODAY()>90)textNO


From the above you'll see that where I have entered "1-10" above 09/10/2024 for the HDLJ MK5 it has applied the conditional formatting because it's treating this as a Date, even though I've Formatted the Cell as Text.

What can be done to stop this from happening?
 
Upvote 0
Did you format the cell as Text before putting the 1-10 in the cell?
 
Upvote 0
Did you format the cell as Text before putting the 1-10 in the cell?
No as it happens, it wasn't until I entered the 1-10 and excited the cell I realised it needed to be Text.

It has now been changed, but made no difference, even tried entering '1-10 to try to force it to Text
 
Upvote 0
Actually it comes up as true in the conditional formatting as the text (now you have converted it) is being seen as greater than any number, you'll have to test if it is a number
Excel Formula:
=AND(ISNUMBER(C6),C6-TODAY()<=90,C6-TODAY()>30)
 
Upvote 0
Solution
Actually it comes up as true in the conditional formatting as the text (now you have converted it) is being seen as greater than any number, you'll have to test if it is a number
Excel Formula:
=AND(ISNUMBER(C6),C6-TODAY()<=90,C6-TODAY()>30)

Many thanks 👍🏼

Works a dream, appreciate your help.
 
Upvote 0
Happy we could help and welcome to the forum (please remember to amend the other conditions in the same way)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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