Cell Formatting Based on Current Date

default_name

Board Regular
Joined
May 16, 2018
Messages
170
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hey everyone,

I have a group of cells in my workbook that I would like to change colors after a certain date.

If today's date falls after the contents of cell AJ1 (which contains a reference date like 9/5/2019) then I want cells AG1:AJ77 to change to black with white font. In other words, since today is 9/12/2019 (which is after the AJ1 date of 9/5/2019) then that group of cells (AG1:AJ77) should be blacked out.

I am trying to implement this on a budget sheet by blacking out certain areas of the budget sheet after each period of the budget passes.
Getting today's date is kind of tricky though...I have seen VBA variations, as well as the use of an EDATE(NOW()) function, but I am just not sure how to best proceed in this case. VBA would be preferred.

Thanks in advance for your help!
:)
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
This can be done pretty easily with Conditional Formatting, which makes it dynamic (you never need to worry about running any code).
Just:
1. Select the range AG1:AJ77
2. Go to Conditional Formatting and select the Formula option (last one)
3. Enter the follow formula: =TODAY() > $AJ$1
4. Select the white font option
5. Click OK

If you really want this in VBA, if you turn on your Macro Recorder, and record yourself performing the steps above, you will have the VBA code to create this Conditional Formatting.
 
Upvote 0
You can use conditional formatting for that.
Select AG1:AJ77 & use this formula
=$AJ$1< Today()
Then select the format.

EDIT:
My turn to be too slow typing. :)
 
Last edited:
Upvote 0
You guys are amazing!!
Quick too!!

Thank you so much!
Works perfectly!
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,485
Messages
6,113,931
Members
448,533
Latest member
thietbibeboiwasaco

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