Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Conditional Formatting Based on Date Proximity.

Conditional Formatting Based on Date Proximity

by Allen Wyatt
(last updated June 23, 2017)

21

Richard wondered if it was possible, using conditional formatting, to change the color of a cell. For his purposes he wanted a cell to be red if it contains today's date, to be yellow if it contains a date within a week of today, and to be green if it contains a date within two weeks.

You can achieve this type of conditional formatting if you apply a formula. For instance, let's assume that you want to apply the conditional formatting to cell A1. Just follow these steps:

  1. Select cell A1.
  2. Choose Conditional Formatting from the Format menu. Excel displays the Conditional Formatting dialog box. (See Figure 1.)
  3. Figure 1. The Conditional Formatting dialog box.

  4. Set Condition 1 so that Cell Value Is Equal To =TODAY(). Note that you must, in the right-most box, enter an equal sign followed by the TODAY() function.
  5. Click on the Format button. Excel displays the Format Cells dialog box.
  6. Make sure the Patterns tab is selected. (See Figure 2.)
  7. Figure 2. The Patterns tab of the Format Cells dialog box.

  8. Choose the red color you want to use and close the Format Cells dialog box.
  9. Click on the Add button.
  10. Set Condition 2 so that Cell Value Is Between =TODAY()-7 And =TODAY()+7. Note that you must use equal signs in the two right-most boxes, otherwise Excel can't figure out that you are entering a formula.
  11. Click on the Format button. Excel displays the Format Cells dialog box.
  12. Make sure the Patterns tab is selected.
  13. Choose the yellow color you want to use and close the Format Cells dialog box.
  14. Click on the Add button.
  15. Set Condition 3 so that Cell Value Is Between =TODAY()-14 And =TODAY()+14. Again, you must include the equal signs to indicate you are entering formulas.
  16. Click on the Format button. Excel displays the Format Cells dialog box.
  17. Make sure the Patterns tab is selected.
  18. Choose the green color you want to use and close the Format Cells dialog box.
  19. Click on OK.

One important thing to bear in mind with conditional formatting is that criteria are evaluated in the order in which they appear. Once a criteria has been met, then the formatting is applied and other criteria are not tested. It is therefore important to set out the tests in the correct order. If, in the example above, the criteria had been entered in the reverse order, i.e. test for 14 days, then 7 and then 0, it would have only applied the 14 days format even if the date entered was today. In other words, if the date is today then all three of the tests would have been met so you have to be careful of the order in order to get the result you need.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2664) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Conditional Formatting Based on Date Proximity.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Controlling the Program Used with Hyperlinked Images

How to tell Windows which program to use for graphics with hyperlinks.

Discover More

Starting in Safe Mode

By using a command-line switch, Excel can be started in safe mode. This means that the program is loaded with bare-bones ...

Discover More

Limiting Spell Checking

Spell check a document, and Word normally checks several different dictionaries. Here's how to limit the dictionary consulted ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Conditional Formatting

One of the powerful features of Excel is the ability to format a cell based on the contents of that cell or another. It is ...

Discover More

Using Multiple Test Conditions

When creating conditional formats, you are not limited to only one condition. You can create up to three conditions, all for ...

Discover More

Sorting or Filtering by Conditional Format Results

Conditional formatting is a great feature in Excel. Unfortunately, you can't sort or filter by the results of that ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight minus 3?

2017-07-11 14:17:45

Allen

Sean,

Not sure how much more plain I can make it. At the bottom of the article it says "This tip (2664) applies to Microsoft Excel 97, 2000, 2002, and 2003." At the upper-right of the page it says this entire SITE is for older versions of Excel. There is also, at the very top in bold and with an icon, an "Important Note" that makes the same point.

At minimum that is three places on the page. How much more obvious can one be?

-Allen


2017-07-11 13:32:38

Sean

These instructions are not applicable to Excel 2016. Time to update, I think. Or at least indicate that these instructions are for older versions of Excel.


2017-01-23 09:14:33

Barry

@Andrew,
In case you haven't sorted this yet.
Select the cell with the milestone end date in it and then open the Conditional Formatting dialog box (Format->Conditional Formatting.....).
Select "Cell Value is", and in the next drop down select "Less Than", and in the value box enter "=TODAY()"; then click "OK"


2017-01-23 07:32:44

Barry

@PJC

Try this formula:
=IF(TODAY()-A1<=7,"On track",ROUNDDOWN((TODAY()-A1)/7,0)&" week(s) late")


2017-01-22 16:57:40

PJC

Hi - I'd like to build a formula that compare the dates in ColumnA to today's date:

If the date value in Col-A is few than 7 days from today, output "On Track";if it's between 7-14, output "1 week late"; if it's between 15-21, output "2 weeks late" and so on. Is that possible?

thanks!


2016-12-07 10:04:04

Andrew Hoeller

Hi I have created a GANTT chart in excel for milestones that we are working against. I have used a start date and a milestone end date but I want to show when a milestone has passed the milestone end date it highlights the cell in red, how do you do this please?
Kind Regards

Andrew


2016-11-10 09:27:43

Pat

I have two dates "Last Bill" and "Next Bill". I import a spreadsheet from a database every couple of days or so. I want to have the spreadsheet to highlight any dates that are older than 30 days or more using the "Next Bill". the information changes and the formulas get taken out. is there a way to do this?


2016-09-23 09:41:28

Hussain

need one formula or method

example type
1

need 'one' (letters)


selected coloumns


2016-04-12 10:47:37

Peter

Thanks for the help, exactly what I needed.


2016-04-12 08:20:50

Mohammed Nufail

I have spread sheet with employee details. I need to do as below.

If I enter a number in a cell all the details of an employee should be fill on that sheet. For an example Mr. Ricky needs to pay sum of money. If I type no. 1 in one cell Mr. Ricky's details should be show to me in that sheet. Is there any options??


2016-03-17 16:32:59

patrick

I was wondering how to get excel to automatically update with alerts or notifications by color and date when you open the spreadsheet?


2015-08-17 06:59:05

Nick

Such a shame that there are no screenshots of the formula entered in the correct places.
I've tried this and obviously am doing something wrong. Pictures paint a thousand words.


2015-08-12 05:14:30

Barry

@ Joleen

You need a small variant to my post on 18th February 2015 below.


2015-08-11 16:47:01

Barry

@Karen

Yes you can. Any formula you can put in a cell can be used in a conditional formatting condition.


2015-08-11 15:34:58

Joleen

I have created a speadsheet where i need to follow up with todays date. Column A has the date in which i'm working with. In Column E i would like a "reminder" to pop up when 15 days has exceeded from todays date. Is this possible.


2015-08-10 15:47:10

Karen

Am I able to make a formula that has Column E's date based on it's relativity to Column D's date?

The only way I can find to do it now it on a single-cell basis.


2015-02-18 08:50:49

Barry

@Charles

If you course dates are in Column A and Course title, description, etc are in Columns B,C,.....

Select all of the course data that you want your colour coding to be applicable to (this can include the course title, description etc).

Set the cells background colour to Green (this is the default) then set the Conditional Formatting as follows:
Assuming the selected range starts with cell A2
Set Condition 1:
select the drop down as "Formula Is" and enter the formula "=$A2<Now()+30" but w/o the quote marks. and set the formatting to "Red"
Click the "Add>>>" button and set Condition 2:
select the drop down as "Formula Is" and enter the formula "=$A2<Now()+60" but w/o the quote marks. and set the formatting to "Yellow"

NB this relies on Condition 1 over-riding Condition 2.


2015-02-18 00:12:27

Charles

Hello,

I am setting up an excel spreadsheet that has training dates inputed into each cell. These training courses are done annually.

What I am trying to do is to get it so when the date is within:

30 Days cell turns red
Between 30 & 60 days cell turns yellow
Everything else cells are green.


2015-01-02 23:36:13

vinny

Your method won't work if I wanted to highlight a cell every time Jan 1st rolls around. It will only work for Jan 1st of the current year. So if I had someone's birthday on a spreadsheet as Jan 1st 1980 then =today() as a conditionally highlighted cell won't work.


2014-08-30 04:48:05

seena

Hello! I am trying to add a value of something today to the total previous value. But I cannot come up with a correct answer.

e.g

DATA:

MONTH/YEAR VALUE
January 2014 100
February 2014 200
March 2014 300
April 2014 400
May 2014 500
June 2014 600
July 2014 700
August 2014 800
September 2014 900
October 2014 1000
November 2014 100
December 2014 200

(ENTER MONTH/YEAR): (1)_____________(SEE DATA ABOVE)

AND THEN,
THE VALUE OF THAT MONTH/YEAR WILL AUTOMATICALLY FILL UP THE (2)BLANK BELOW

VALUE : (2)_____________( I USE VLOOKUP HERE TO COME OUT THE VALUE IN A SPECIFIED MONTH/YEAR)

TO DATE VALUE:(3)_____________ (THE RESULT SHOULD BE THE TOTAL SUM OF PREVIOUS VALUE OF MONTH/YEAR AND A VALUE OF A MONTH/YEAR IN (2)BLANK.

I WANNA SEE A RESULT THAT EVERY TIME I CHANGE THE MONTH/YEAR IN (1)BLANK THE SAME PROCEDURE WILL FOLLOW.

LITERAL EXAMPLE:(SEE DATA)
BLANKS
(FILL UP) (1) MARCH 2014
(RESULT) (2) 300
(TO DATE VALUE) (3) 600

I WOULD BE VERY GRATEFUL IF YOU COULD ANSWER MY PROBLEM LIKE THIS.


2014-07-31 14:51:08

Jane

I am trying to create a formula in 2007 Excel that will allow me to type a date into the first cell of a column and then auto fill cells in the same column with previous dates month to month for 12 months (e.g., If I typed:
February 28, 2014
January 31, 2014
December 31, 2013
November 30, 2013, etc.).

Can that be accomplished? Thanks!


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.