
Tips.Net > ExcelTips Home > Formatting > Conditional Formatting > Shading Based on Odds and Evens
Summary: Given a series of values in a range of cells, you may want to shade the cells based on whether the values are odd or even. Using Conditional Formatting you can make short work out of such a need. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
If you have a series of values in a range of cells, you might want to use different formatting to differentiate the odd numbers from the even numbers. The way you do this is through the use of the Conditional Formatting feature in Excel. Follow these steps:
With this conditional formatting applied, if the cell is odd it will be one color and if even it will be another. If the cell contains text, the cell will be uncolored, meaning it will have the color of the cell before you added the conditional formatting. The conditional formatting overrides any formatting you put on the cell, so even if you try to change the cell color via the toolbar, the conditional formatting takes precedence.
It is interesting to note that if you have the Analysis ToolPak enabled in Excel, you might be tempted to use the ISODD and ISEVEN functions in the conditional format. These functions cannot apparently be used with conditional formatting. If you try to do so, Excel generates an error that says "You may not use references to other worksheets or workbooks for Conditional Formatting criteria." The best bet is to use the MOD function, as described above.
Tip #2767 applies to Microsoft Excel versions: 97 2000 2002 2003
Got the Time? If you work with either times or dates in Excel, you really need ExcelTips: Times and Dates. Everything you need to know about slicing, dicing, and generally working with times and dates.
Want to make Excel do even more? The way is easy when you know how to use macros. This great e-book makes it easy. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site