
Tips.Net > ExcelTips Home > Formatting > Conditional Formatting > Understanding Color and Conditional Formatting Codes
Summary: Using custom formatting, you can format a cell so that different types of values display exactly as you want them to. This tip explains how to create the custom formats and the pertinent formatting codes that are available. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 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 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. |
Tip #2136 applies to Microsoft Excel versions: 97 2000 2002 2003
More Power! For some people, the prospect of creating macros can be scary. Those who conquer their fears, however, find they become much more confident and productive once they learn how to make Excel do exactly what they want. ExcelTips: The Macros is an invaluable source for learning Excel macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of ExcelTips. Learn at your own pace, exactly the way you want.
Check out ExcelTips: The Macros today!
Add power to your purpose with Excel. A comprehensive 500+ page e-book explains everything you need to know about macros. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips
Advertise on the
ExcelTips Site