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: Shading Based on Odds and Evens.

# Shading Based on Odds and Evens

by Allen Wyatt
(last updated August 24, 2017)

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:

1. Select the cells that contain the odd and even values.
2. Choose Conditional Formatting from the Format menu. Excel displays the Conditional Formatting dialog box.
3. Using the left-most drop-down list, choose Formula Is. (See Figure 1.)
4. Figure 1. The Conditional Formatting dialog box.

5. In the formula area, enter =MOD(A1,2)=1. This formula will return True if the cell contains an odd value.
6. Click on Format and change the format to reflect the formatting you want applied for cells containing odd values.
7. In the Conditional Formatting dialog box, click the Add button.
8. Repeat steps 3 through 5 for the second condition, but use the formula =MOD(A1,2)=0. This condition returns True if the cell contains an even value.
9. Click on OK to apply the conditional formats to the cells.

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2767) 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: Shading Based on Odds and Evens.

##### 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

Removing Tabs Used to Indent a Paragraph

You get a document from a colleague and you notice that each paragraph starts with a tab character. Here are a couple of ...

Discover More

Checking for Incorrect Numbers in Text

Word's grammar checker can help you correct many of the more common errors that can crop up while writing. This includes ...

Discover More

Renaming and Deleting Icons

Want to change the name of a desktop icon or get rid of it entirely? It's easier to do than you probably think!

Discover More

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!

Conditional Formatting Based on Date Proximity

Conditional formatting can be used to draw your attention to certain cells based on what is within those cells. This tip ...

Discover More

Diagonal Borders in a Conditional Format

Conditional formatting is a great tool for changing how your data looks based on the data itself. Excel won't allow you ...

Discover More

Understanding Conditional Formatting Conditions

Conditional formatting can be a great way to highlight specific information in your worksheets. This tip explains the ...

Discover More
##### Subscribe

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

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 five more than 3?

2015-10-19 19:26:55

Mr. Allen,
Thank you for the inform. tips.
There is one tiny issue I'd like to make you aware off which is: When I tried to follow your tips about coloring odd and even numbers I failed to get the result, because you suggested this:"In the formula area, enter =MOD(A1,2)=1. This formula will return True if the cell contains an odd value..."
Bur in Excel 2003 (what I have) the formula should be: =MOD(A1;2)=1. Replacing the coma with semi Colon. Now the tip works.

Best Regards,

##### 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.