Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Conditional Formatting Based on Date Proximity

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.

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.

Related Tips:

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Hussain    23 Sep 2016, 09:41
need one formula or method

example type
1

need 'one' (letters)
 

selected coloumns
Peter    12 Apr 2016, 10:47
Thanks for the help, exactly what I needed.
Mohammed Nufail    12 Apr 2016, 08:20
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??
patrick    17 Mar 2016, 16:32
I was wondering how to get excel to automatically update with alerts or notifications by color and date when you open the spreadsheet?
Nick    17 Aug 2015, 06:59
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.
Barry    12 Aug 2015, 05:14
@ Joleen

You need a small variant to my post on 18th February 2015 below.
Barry    11 Aug 2015, 16:47
@Karen

Yes you can. Any formula you can put in a cell can be used in a conditional formatting condition.
Joleen    11 Aug 2015, 15:34
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.
Karen    10 Aug 2015, 15:47
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.
Barry    18 Feb 2015, 08:50
@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.
Charles    18 Feb 2015, 00:12
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.
vinny    02 Jan 2015, 23:36
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.
seena    30 Aug 2014, 04:48
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.
Jane    31 Jul 2014, 14:51
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!
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.