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.
by Allen Wyatt
(last updated June 23, 2017)
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:
Figure 1. The Conditional Formatting dialog box.
Figure 2. The Patterns tab of the Format Cells dialog box.
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.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Conditional formatting is a great tool for changing how your data looks based on the data itself. Excel won't allow you to ...Discover More
Conditional formatting is a great tool. You may need to use this tool to tell the difference between cells that are empty or ...Discover More
There are many times when you are creating a worksheet that you need to analyze dates within that worksheet. Once such ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.