How to Create Custom Number Formats in Microsoft Excel

Standard number formatting in Microsoft Excel—such as General, Number, Currency, or Percentage—often proves inadequate when formatting specialized financial models, technical specifications, or inventory dashboards. Analysts frequently resort to text conversion functions like TEXT or manually type unit labels like “kg” or “units” directly into cells. However, converting numerical data into text strings strips away calculation capabilities, causing downstream formulas like SUM, AVERAGE, and VLOOKUP to return errors.

Custom number formatting solves this challenge by altering only the visual presentation of numbers on the worksheet surface while leaving the underlying numerical values intact for formulas and mathematical operations.

Understanding the Four-Section Syntax of Excel Formatting

Every custom number format in Excel is structured into up to four distinct code sections, separated by semicolons:

POSITIVE;NEGATIVE;ZERO;TEXT

Excel evaluates cell contents from left to right against this structure:

  • Section 1 (Positive): Defines formatting for numbers greater than zero.
  • Section 2 (Negative): Defines formatting for numbers less than zero.
  • Section 3 (Zero): Defines how exact zero values are displayed.
  • Section 4 (Text): Defines formatting when non-numeric text strings are entered into the cell.

If you specify only one format section, Excel applies it uniformly to all numbers. If you specify two sections, the first formats positive numbers and zeros, while the second formats negative numbers.

Essential Formatting Placeholders and Symbols

To construct tailored formatting strings, utilize Excel’s built-in digit placeholders:

  • 0 (Zero): A mandatory digit placeholder. If the number has fewer digits than specified zeros, Excel displays leading or trailing zeros (e.g. 0012).
  • # (Hash): An optional digit placeholder. Displays significant digits while suppressing insignificant leading or trailing zeros.
  • ? (Question Mark): A space-alignment placeholder. Adds invisible spacing for non-significant zeros to align decimal points vertically across columns in printed reports.
  • , (Comma): Placed between digit placeholders, it acts as a thousand separator (e.g. #,##0). Placed at the end of a format, it scales numbers down by thousands.
  • @ (At Symbol): Represents where text entered into the cell should appear within custom text templates.

Adding Custom Units, Suffixes, and Currencies

To display engineering units, inventory counts, or non-standard currencies without corrupting the underlying math:

  1. Highlight the target cells and press Ctrl + 1 (or right-click and choose Format Cells).
  2. Select the Number tab and click the Custom category at the bottom of the list.
  3. In the Type input field, enter your custom formatting string, enclosing literal words in quotation marks:
#,##0.0 "kg"
  1. Click OK. Typing 45.2 into a cell displays visually as 45.2 kg, yet formulas like =A1*2 evaluate accurately to 90.4.
  2. For financial metrics requiring custom currency codes and zero placeholders:
£#,##0;[Red]-£#,##0;"-"

This layout renders positive values with a pound symbol, displays negative values in bright red with a minus sign, and displays a clean em-dash whenever a value is zero.

Applying Built-In Colours to Numbers

Excel provides eight native colour keywords that can be placed in square brackets at the start of any formatting section:

  • [Black], [White], [Red], [Green], [Blue], [Yellow], [Magenta], [Cyan]

For example, to format positive margins in green, deficits in red, and zero balances in muted black:

[Green]+#,##0.0%;[Red]-#,##0.0%;[Black]0.0%

Defining Custom Numerical Thresholds and Scaling

You are not restricted to positive and negative conditions. You can declare custom numerical comparisons inside square brackets:

[>=1000000]$#,##0.0,,"M";[>=1000]$#,##0.0,"K";$#,##0

Notice the trailing commas in this formula:

  • A single comma immediately preceding the suffix divides the displayed number by 1,000 (abbreviating 50,000 to $50.0K).
  • Two consecutive commas divide the displayed value by 1,000,000 (abbreviating 2,500,000 to $2.5M).

Suppressing Display and Hiding Sensitive Cell Data

To completely hide numbers and text from displaying on a worksheet without clearing the cells or altering formula dependencies, enter three consecutive semicolons into the Custom format box:

;;;

The cell contents remain fully active and readable in the formula bar, but appear completely invisible on the printed worksheet surface.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.