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: Understanding Color and Conditional Formatting Codes.

Understanding Color and Conditional Formatting Codes

Written by Allen Wyatt (last updated August 15, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


In other issues of ExcelTips you learn how formatting codes are used to create custom formats used to display numbers, dates, and times. Excel also provides formatting codes to specify text display colors, as well as codes that indicate conditional formats. These formats only use a specific format when the value being displayed meets a certain criteria.

To understand these codes a bit better, take a look at this format within the Currency category:

$#,##0.00_);[Red]($#,##0.00)

Notice there are two number formats divided by a semicolon. If there are two formats like this, Excel assumes that the one on the left is to be used if the number is 0 or above, and the one on the right is to be used if the number is less than 0. This example results in all numbers having a dollar sign, a comma being used as a thousands separator, amounts less than $1.00 having a leading 0, and negative values being shown in red with surrounding parentheses. The _) part of the left format is used so that positive and negative numbers align properly (positive numbers will leave a space the same width as a right parenthesis after the number).

You are not limited to only two formats, as in this example. You can actually use four formats, each separated by a semicolon. The first is used if the value is above 0, the second is used if it is below 0, the third is used if it is equal to 0, and the fourth is used if the value being displayed is text.

The following table shows the color and conditional formatting codes. As you may have surmised, these codes are used with the formatting codes mentioned at the beginning of this tip as being in other issues of ExcelTips.

Symbol Effect
[Black] Black type.
[Blue] Blue type.
[Cyan] Cyan type.
[Green] Green type.
[Magenta] Magenta type.
[Red] Red type.
[White] White type.
[Yellow] Yellow type.
[COLOR x] Type in color code x, where x can be any value from 1 to 56.
[= value] Use this format only if the number equals this value.
[< value] Use this format only if the number is less than this value.
[<= value] Use this format only if the number is less than or equals this value.
[> value] Use this format only if the number is greater than this value.
[>= value] Use this format only if the number is greater than or equals this value.
[<> value] Use this format only if the number does not equal this value.

Note the COLOR code, where you can specify one of 56 different colors to be used in the format. If you would like additional information on what those 56 different colors are, you can find a helpful table at this address:

http://dmcritchie.mvps.org/excel/colors.htm#colorindex

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2136) 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: Understanding Color and Conditional Formatting Codes.

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

Returning a Weight and a Date

If you have two columns containing dates and weights from those dates, you may want to pick a date associated with a ...

Discover More

Counting the Times a Worksheet is Used

Do you need to know how many times a worksheet has been used? Excel doesn't track that information, but you can develop ...

Discover More

Maintaining Formatting when Inserting Documents

Word allows you to easily insert the contents of one document into another. Doing so, however, may result in unintended ...

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!

More ExcelTips (menu)

Changing the Percent Symbol

Some symbols can be easily changed in Excel or in Windows, such as the symbols used for currency and to separate ...

Discover More

No More Custom Formats Can Be Added

If you make too many formatting changes to your workbook, you could end up with a situation where you cannot make any ...

Discover More

Moving Custom Formats to Number Formatting Categories

Moving your custom formats into a formatting category other than "custom" isn't something you can do in Excel. Here's ...

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}] (all 7 characters, in the sequence shown) 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 seven minus 2?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.