Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Understanding Color and Conditional Formatting Codes.

Understanding Color and Conditional Formatting Codes

Written by Allen Wyatt (last updated February 17, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

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

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8352) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel 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

Switching between Program Windows

It is not unusual for you to work with several (and sometimes many) programs at the same time. Each program is displayed ...

Discover More

Noting Changes at the Left of the Text

The Track Changes feature allows you to easily see where changes have been made in a document. Resolve those changes, and ...

Discover More

Accessing Stock Information

Do you follow the stock market? If you do and you want to get stock information into a worksheet, there are some new ways ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Adding a Custom Format to those Offered by Excel

Adding a custom format to Excel is easy. Having that custom format appear in all your workbooks is a different story ...

Discover More

Handling Negative Numbers in a Complex Custom Format

Custom formats are great for defining how a specific value in a cell should look. They aren't that great at doing complex ...

Discover More

Easy Value Hiding

Want a quick and easy way to hide the information in a cell? You can do it with a simple three-character custom format.

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 9 + 4?

2018-09-08 12:58:32

Ronmio

A list of the 56 colors in the COLOR X palette can be found at http://access-excel.tips/excel-vba-color-code-list/ .

Even more details about Excel's color palette, including the HTML and RGB values of the 56 colors, can be found at http://dmcritchie.mvps.org/excel/colors.htm . The latter also includes a lot of examples of dealing with color in macros including the VBA code that David McRitchie used to create his color table.

An interesting tangent is David McRitchie's macros for converting selections in an Excel sheet into compact HTML. That's what he used to convert his color table in Excel to HTML for the webpage mentioned above. Information about his free XL2HTML tool can be found at http://dmcritchie.mvps.org/excel/xl2html.htm


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.