Excel custom number formatting tutorial

Get the Custom Number Formatting Practice Workbook

Follow the examples and practice changing how numbers appear in Excel without changing their underlying values.

Custom number formatting in Excel helps you present your data clearly and effectively. Let’s explore some simple tips to save you time and avoid common mistakes.

Display Numbers in Millions in Excel

To make large numbers easier to read, you can display them in millions without changing their underlying values. For example, a value of 45,985,128 can appear as 46M.

Excel sales numbers displayed in millions with an M suffix
  • Select Your Cells: Highlight the cells with the numbers you want to format.
  • Open Format Cells: Press CTRL + 1 or right-click and choose “Format Cells”.
  • Go to Custom Format: In the “Number” tab, select “Custom”.
  • Enter Format Code: In the “Type” field, enter 0,, "M"

The format 0,,"M" divides the displayed value by one million and adds M. The original number remains unchanged, so formulas still calculate with the full value.

Show Millions with One Decimal Place

Use 0.0,,"M" to display one decimal place. For example, 45,985,128 appears as 46.0M.

Add Thousands Separators Without Decimals

You don’t need a custom format code for every task. Excel’s built-in Number format can display thousands separators and remove decimal places in a few clicks.

Excel compensation values before and after adding thousands separators
  • Select Your Cells: Highlight the cells you want to format.
  • Open Format Cells: Press Ctrl + 1 or right-click and choose “Format Cells”.
  • Go to Number Tab: In the “Number” tab, select “Number”.
  • Use 1000 Separator: Check the box for “Use 1000 Separator (,)”.
  • Set Decimal Places: Change “Decimal Places” to 0.
Excel Format Cells dialog with thousands separator enabled and zero decimal places

Hide Zero Values Without Deleting Them

To hide zero values in Excel, follow these simple steps:

Excel compensation report with zero values hidden using custom number formatting
  • Select Your Cells: Highlight the cells where you want to hide zeros.
  • Open Format Cells: Press Ctrl + 1 to open the Format Cells dialog.
  • Go to Custom Category: Select “Custom” from the list.
  • Enter Format Code: In the “Type” field, enter #,##0;-#,##0;

This format displays positive numbers with a thousands separator, negative numbers with a minus sign and zero values as blanks. The zeros remain in the cells and are still included in calculations.

For another practical use of number formats, see how to show up and down arrows with custom formatting.

Excel formula bar showing that a visually hidden zero remains in the cell

How Excel Custom Number Formats Work

A custom number format can have up to four sections, separated by semicolons. The sections control how Excel displays positive numbers, negative numbers, zero values and text, in that order. You can omit sections when you don’t need them.

  • Positive Numbers: Format for positive values.
  • Negative Numbers: Format for negative values.
  • Zero Values: Format for zeros.
  • Text: Format for text entries.
Four custom number format sections for positive numbers negative numbers zeros and text

Display Text Instead of Zero

The third section of #,##0;-#,##0;"zero values"; tells Excel to display the words “zero values” when a cell contains zero. The actual value remains numeric, so calculations such as =B5+5 still work.

For example, to display “zero values” in cells with a zero:

  • Select Your Cells: Highlight the cells you want to format.
  • Open Format Cells: Press Ctrl + 1 or right-click and choose “Format Cells”.
  • Go to Custom Format: In the “Number” tab, select “Custom”.
  • Enter Format Code: In the “Type” field, enter #,##0;-#,##0;"zero values";
Excel custom number format code that displays zero values as text

The cell will display “zero values” for zeros.

Excel cell displaying zero values as words while the formula bar shows zero

The formula bar will still show the number zero, and you can perform calculations like =B5 + 5, which will return 5.

=B5 + 5

…and we will see the answer 5.

Excel formula adding five to a zero displayed with custom text formatting

Reuse Custom Number Formats

Once you create a custom number format, it becomes available in the Custom category for reuse within that workbook. You can select it again instead of typing the code from scratch.

You can use them repeatedly without recreating them.

Custom number formats saved in Excel Format Cells dialog

This library is also a great learning tool to see and modify your favorite formats, saving you time.

The Difference Between 0 and #

The 0 placeholder displays a digit even when a leading or trailing zero is needed. The # placeholder doesn’t add unnecessary zeros.

For example, applying 0.00 to 0.5 displays 0.50, while #.00 displays .50.

Pound signs are also useful for defining comma separators. For instance, #,##0 will display 1234 as 1,234 and 12 as 12.

Add Leading Zeros to Numbers

Need to display numbers with leading zeros in Excel? Here’s how you can do it, especially useful for product codes or postal codes.

Excel product codes before applying leading zeros
  • Select Your Cells: Highlight the cells with the numbers you want to format.
  • Open Format Cells: Press Ctrl + 1 or right-click and choose “Format Cells”.
  • Go to Custom Format: In the “Number” tab, select “Custom”.
  • Enter Format Code: In the “Type” field, enter 0000 for a 4-digit number.
Excel custom number format 0000 for four-digit product codes

The result will be product codes displayed as follows.

Excel product codes displayed with leading zeros

Custom formatting changes how a number appears, not the value stored in the cell. If the code needs to retain its leading zeros when exported or contains 16 or more digits, store it as text instead. Excel only preserves 15 significant digits in numeric values.

Add Text to Numbers Without Breaking Formulas

Typing words directly into a numeric cell can turn the entry into text and interfere with calculations. A custom number format lets you display a label alongside a number while keeping the underlying value numeric.

Let’s say, if a value in your list is negative, you want to add the text “(Return)”.

Excel negative number displayed with a Return label using custom formatting
  • Select Your Cells: Highlight the cells with the values.
  • Open Format Cells: Press Ctrl + 1 or right-click and choose “Format Cells”.
  • Go to Custom Format: In the “Number” tab, select “Custom”.
  • Enter Format Code: In the “Type” field, enter #;-# "(Return)".

This format adds “(Return)” after negative numbers. For example, -120 appears as -120 (Return). The cell still contains -120, which means SUM and other calculations continue to work.

Excel custom number format code for adding Return after negative values

This will display negative values with “(Return)” next to them. The numbers remain usable for calculations.

Excel sales values with a negative amount labeled Return

If you need to combine numbers with text in a separate formula result, see how to combine text and numbers with Excel’s TEXT function.

Add a Total Label Without Converting the Number to Text

You can also display a label alongside a calculated total without turning the result into text.

For example, suppose you’ve used SUM to calculate the total sales value. Instead of typing “Total” directly into the cell, apply this custom number format:

#,##0 "Total"

A value of 1250 will appear as 1,250 Total. The cell still contains the number 1250, so you can continue using it in formulas.

To apply the format, select the total cell, press Ctrl+1, choose Custom, enter the format code and click OK.

Tip: Put any text you want to display in double quotation marks inside the custom number format.

Hide Cell Contents Without Deleting Them

You can hide data in Excel using custom number formatting. This method uses the four-segment codes, and leaving a segment blank hides that type of data.

  • Open Format Cells: Select your cells and press Ctrl + 1 or right-click and choose “Format Cells”.
  • Go to Custom Format: In the “Number” tab, select “Custom”.
  • Enter Format Code: To hide all data, enter ;;; (three semicolons) in the “Type” field.

The format ;;; hides the displayed contents of a cell without deleting its value. The value remains accessible in the formula bar and to formulas that reference the cell. This is a display trick, not a way to protect confidential information.

Excel custom number format with three semicolons to hide cell contents

This will hide positive numbers, negative numbers, zeros, and text, displaying nothing in the cell.

Remove Custom Number Formatting

If you want to return cells to their original format, follow these steps:

  • Select Your Cells: Highlight the cells you want to reset.
  • Choose General Format: Go to the Number Formatting dropdown and select “General”.
Excel number format dropdown showing General Number Currency and Accounting

Choosing General removes the custom number format and shows the underlying value using Excel’s default display rules. It doesn’t change or restore values that were already altered before formatting was applied.

Download the Custom Number Formatting Practice Workbook

Download the Custom Number Formatting Practice Workbook

Get the practice file and explore custom formats for zeros, product codes, negative values and more.

Frequently Asked Questions

Does custom number formatting change the actual value in Excel?

No. Custom number formatting changes how a value appears, not the underlying number. Formulas still use the original value, which you can see in the formula bar.

How do I display numbers in millions without changing their values?

Select the cells, press Ctrl+1, choose Custom, and enter 0,,"M". For example, 45,985,128 appears as 46M, but Excel still calculates with the full number.

What do the four sections of an Excel custom number format mean?

The sections control positive numbers, negative numbers, zeros and text, in that order. They are separated by semicolons. You can leave sections empty to hide certain types of values.

How can I hide zero values without deleting them?

Apply the custom number format #,##0;-#,##0;. The empty third section hides zeros, but the cells still contain zero and remain usable in calculations.

How do I add leading zeros to numbers in Excel?

Use a custom format such as 0000 to display 25 as 0025. This changes the appearance only. For identifiers containing 16 or more digits, store the values as text because Excel preserves only 15 significant digits in numeric values.

Can I add text such as Total to a number without breaking formulas?

Yes. Use a custom number format such as #,##0 "Total". A value of 1250 appears as 1,250 Total, but the cell remains numeric and can still be used in SUM and other formulas.

Leila Gharani

Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.