A custom number format changes how a value looks without changing the value itself. The format code has up to four sections — positive;negative;zero;text — each styled independently.
The example
One format code, four behaviors.
| A | B | |
|---|---|---|
| 1 | Value | Displays as |
| 2 | 1250 | 1,250 |
| 3 | −1250 | (1,250) in red |
| 4 | 0 | – |
The formula
Four sections, separated by semicolons:
How it works
Each section styles a different kind of value:
- Section 1 = positive numbers, 2 = negative, 3 = zero, 4 = text.
- Codes:
0forces a digit,#shows a digit only if needed,,is the thousands separator,@is the text placeholder. - Add colors in brackets:
[Red],[Blue], and literal text in quotes:"USD "0. - Apply via Format Cells → Number → Custom. The underlying number is unchanged — formulas still see the true value.
Fewer sections is fine. One section applies to everything; two sections are positive;negative. You only need all four when zero and text deserve special treatment. To bake a format into text, mirror the code in TEXT(value, "…").
Try it: interactive demo
See how a value displays under the 4-section code.
Variations
Two sections
Positive ; negative only:
Add a label
Literal text in the code:
As TEXT()
Bake the format into a string:
Pitfalls & errors
Format ≠ value. A cell showing “–” or “(1,250)” still holds the real number; formulas use the true value, not the display.
Section order is fixed. It’s always positive;negative;zero;text — you can’t reorder them.
0 vs #. 0 pads with zeros (showing 007); # does not. Mixing them up changes leading/trailing zeros.
Practice workbook
Frequently asked questions
What are the sections in an Excel custom number format?
Does a custom format change the cell's value?
What's the difference between 0 and # in a format code?
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