Put conditions right inside a number format code with [brackets] — color values by threshold or apply different formats above and below a cutoff, all without a conditional-formatting rule.
The example
Scores colored by a 100 threshold via the format code.
| A | B | |
|---|---|---|
| 1 | Value | Displays |
| 2 | 120 | 120 (green) |
| 3 | 85 | 85 (red) |
The formula
Conditions in square brackets:
How it works
Bracketed conditions choose the section:
- Put a condition in brackets at the start of a section:
[>=100]. - Add a color in brackets too:
[Green],[Red],[Blue]. - Sections are evaluated in order; with conditions you get up to two custom conditions plus a default third section.
- Apply via Format Cells → Custom. It styles the number in place, no separate rule needed.
Limited to colors and conditions, not fills. Number-format conditions can change font color and digits, but can’t set a cell background or use more than two conditions. For fills, icon sets, or richer logic, use real Conditional Formatting instead.
Try it: interactive demo
≥100 green, <100 red (via format code).
Variations
Three-way
Condition + condition + default:
Show status text
Replace number with a word:
Use CF for fills
Background color → Conditional Formatting.
Pitfalls & errors
Max two conditions. A format code allows two bracketed conditions plus a default section — need more? Use Conditional Formatting.
No background fills. Number formats change font color/text only, never the cell fill.
Conditions use comparison operators. [>=100], [<0] — put the operator and value inside the brackets, before the format.
Practice workbook
Frequently asked questions
How do I color numbers by value with a format code?
How many conditions can a number format have?
Can a number format change the cell background?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class