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 January 20, 2018)

2

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

Upside-Down Printing

Putting words on the printed page is easy in Word. Rotating those words in different manners can be a bit trickier. This ...

Discover More

Appending to a Non-Document Text File

Your macros can easily add information to the end of an existing text file. This is done by opening the target file in ...

Discover More

Finding Text in Text Boxes

Want to search for text that may appear in a text box rather than in a regular worksheet cell? You can only perform the ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Conditional Formats that Distinguish Blanks and Zeroes

Conditional formatting is a great tool. You may need to use this tool to tell the difference between cells that are empty ...

Discover More

Shading Based on Odds and Evens

You can use conditional formatting to add shading to various cells in your worksheet. This tip shows how you can shade ...

Discover More

Highlighting Cells Containing Specific Text

If you want to highlight cells that contain certain characters, you can use the conditional formatting features of Excel ...

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 6Mpixels. 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 4 + 1?

2018-05-06 06:43:34

Andrew Ford

Hi,
So I have followed your explanation, with adjustment to my requirements. However, no conditional formatting is being applied.

I have a date, let's say 06/09/2018, they do vary.
I want to format backwards on a 28-day rule, so my rules entered are:
Cell Value equal to =TODAY() -84, format RED, this identifies anything entering 3 months
Cell Value between =TODAY() -84 and =TODAY()-112, format Yellow, this identifies anything between 3 / 4 months
Cell Value between =TODAY() -112 and =TODAY()-140, format Yellow, this identifies anything between 4/ 5 months

Where am I going wrong, I just need to identify dates when they approach a month period.


2018-02-20 11:21:55

Lee

What about when I don't want to the data to be determined on TODAY's date.
For example,
Column A - Date of Initial Contact
Column B - Date of Final Contact

I want to use conditional formatting to show:
Green - if communication was completed in 4 days or less
Yellow - if communication was completed in 5-7 days
Red - if it took 10 or more days to complete communication.


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.