Custom Excel Number Format
Custom Excel Number Format
This tutorial explains the basics of the Excel number format and provides the detailed guidance to create custom
formatting. You will learn how to show the required number of decimal places, change alignment or font color,
display a currency symbol, round numbers by thousands, show leading zeros, and much more.
Microsoft Excel has a lot of built-in formats for number, currency, percentage, accounting, dates and times.
But there are situations when you need something very specific. If none of the inbuilt Excel formats meets
your needs, you can create your own number format.
Number formatting in Excel is a very powerful tool, and once you learn how to use it property, your options
are almost unlimited. The aim of this tutorial is to explain the most essential aspects of Excel number format
and set you on the right track to mastering custom number formatting.
Add indents
Repeat characters
Change alignment
1. Select a cell for which you want to create custom formatting, and press Ctrl+1 to open the Format Cells
dialog.
Done!
Tip. Instead of creating a custom number format from scratch, you choose a built-in Excel format close to
your desired result, and customize it.
Wait, wait, but what do all those symbols in the Type box mean? And how do I put them in the right
combination to display the numbers the way I want? Well, this is what the rest of this tutorial is all about :)
1. Format for positive numbers (display 2 decimal places and a thousands separator).
2. Format for negative numbers (the same as for positive numbers, but enclosed in parentheses).
1. A custom Excel number format changes only the visual representation, i.e. how a value is displayed in a
cell. The underlying value stored in a cell is not changed.
2. When you are customizing a built-in Excel format, a copy of that format is created. The original number
format cannot be changed or deleted.
3. Excel custom number format does not have to include all four sections.
If a custom format contains just 1 section, that format will be applied to all number types - positive,
negative and zeros.
If a custom number format includes 2 sections, the first section is used for positive numbers and zeros,
and the second section - for negative numbers.
A custom format is applied to text values only if it contains all four sections.
4. To apply the default Excel number format for any of the middle sections, type General instead of the
corresponding format code.
For example, to display zeros as dashes and show all other values with the default formatting, use this
format code: General; -General; "-"; General
Note. The General format included in the 2nd section of the format code does not display the minus
sign, therefore we include it in the format code.
5. To hide a certain value type(s), skip the corresponding code section, and only type the ending semicolon.
For example, to hide zeros and negative values, use the following format code: General; ; ; General.
As the result, zeros and negative value will appear only in the formula bar, but will not be visible in cells.
6. To delete a custom number format, open the Format Cells dialog, select Custom in the Category list, find the
format you want to delete in the Type list, and click the Delete button.
Digit and text placeholders
For starters, let's learn 4 basic placeholders that you can use in your custom Excel format.
As you may have noticed in the above screenshot, the digit placeholders behave in the following way:
If a number entered in a cell has more digits to the right of the decimal point than there are placeholders
in the format, the number is "rounded" to as many decimal places as there are placeholders.
For example, if you type 2.25 in a cell with #.# format, the number will display as 2.3.
All digits to the left of the decimal point are displayed regardless of the number of placeholders.
For example, if you type 202.25 in a cell with #.# format, the number will display as 202.3.
Below you will find a few more examples that will hopefully shed more light on number formatting in Excel.
Format Description Input value Display as
2 2.00
#.00 Always display 2 decimal places. 2.5 2.50
0.5556 .56
2 2.
Shows up to 2 decimal places,
#.## 2.5 2.5
without insignificant zeros.
0.5556 0.56
2 2.0
Display a minimum of 1 and a
#.0# 2.205 2.21
maximum of 2 decimal places.
0.555 .56
22.55 22.55
Display up to 3 decimal places with 2.5 2.5
???.???
aligned decimals. 2222.5555 2222.556
0.55 .55
@ Text placeholder
The difference between 0 and # in the integer part of the format code is as follows. If the format code has only
pound signs (#) to the left of the decimal point, numbers less than 1 begin with a decimal point. For example,
if you type 0.25 in a cell with #.00 format, the number will display as .25. If you use 0.00 format, the number
will display as 0.25.
For example, if a cell format is #.00, and you type 5000 in that cell, the number 5.00 is displayed. For more
examples, please see the screenshot below:
For example, to indicate that numbers are rounded by thousands and millions, you can add \K and \M to the
format codes, respectively:
Tip. To make the number format better readable, include a space between a comma and backward slash.
The following screenshot shows the above formats and a couple more variations:
And here is another example that demonstrates how to display text and numbers within a single cell.
Supposing, you want to add the word "Increase" for positive numbers, and "Decrease" for negative numbers.
All you have to do is include the text enclosed in double quotes in the appropriate section of your format
code:
In addition, the following characters can be included in Excel custom format codes without the use of
backslash or quotation marks:
Symbol Description
: Colon
^ Caret
' Apostrophe
{} Curly brackets
= Equal sign
/ Forward slash
! Exclamation point
& Ampersand
~ Tilde
Space character
A custom Excel number format can also accept other special symbols such as currency, copyright, trademark,
etc. These characters can be entered by typing their four-digit ANSI codes while holding down the ALT key.
Here are some of the most useful ones:
™ Alt+0153 Trademark
You can also create a custom Excel format that combines some specific text and the text typed in a cell. To do
this, enter the additional text enclosed in double quotes in the 4th section of the format code before or after
the text placeholder (@), or both.
For example, to proceed the text typed in the cell with some other text, say "Shipped in", use the following
format code:
Other currency symbols are not available on most of standard keyboards. But you can enter the popular
currencies in this way:
Use the numeric keypad to type the ANSI code for the currency symbol you want to display.
€ Euro ALT+0128
Open the Format Cells dialog, select Currency under Category, and choose the desired currency from the
Symbol drop-down list, e.g. Russian Ruble:
Switch to Custom category, and modify the built-in Excel format the way you want. Or, copy the currency
code from the Type field, and include it in your own number format:
How to display leading zeros with Excel custom format
If you try entering numbers 005 or 00025 in a cell with the default General format, you would notice that
Microsoft Excel removes leading zeros because the number 005 is same as 5. But sometimes, we do want 005,
not 5!
The simplest solution is to apply the Text format to such cells. Alternatively, you can type an apostrophe (') in
front of the numbers. Either way, Excel will understand that you want any cell value to be treated as a text
string. As the result, when you type 005, all leading zeros will be preserved, and the number will show up as
005.
If you want all numbers in a column to contain a certain number of digits, with leading zeros if needed, then
create a custom format that includes only zeros.
As you remember, in Excel number format, 0 is the placeholder that displays insignificant zeros. So, if you
need numbers consisting of 6 digits, use the following format code: 000000
And now, if you type 5 in a cell, it will appear as 000005; 50 will appear as 000050, and so on:
Tip. If you are entering phone numbers, zip codes, or social security numbers that contain leading zeros,
the easiest way is to apply one of the predefined Special formats. Or, you can create the desired custom
number format. For example, to properly display international seven-digit postal codes, use this format:
0000000. For social security numbers with leading zeros, apply this format: 000-00-0000.
For example, to display percentages as integers, use this format: #%. As the result, the number 0.25 entered
in a cell will appear as 25%.
To display percentages with 2 decimal places and a thousands separator, use this one: #,##.00%
For decimal numbers to appear as fractions, include forward slash (/) in your format code, and separate an
integer part with a space. For example:
###/### - displays an improper fraction (a fraction whose numerator is larger than or equal to the
denominator) with up to 3 digits.
To round fractions to a specific denominator, supply it in your number format code after the slash. For
example, to display decimal numbers as eighths, use the following fixed base fraction format: # #/8
Tip. To enter a fraction in a cell formatted as General, preface the fraction with a zero and a space. For
instance, to enter 4/8 in a cell, you type 0 4/8. If you type 4/8, Excel will assume you are entering a date, and
change the cell format accordingly.
Most of the format codes we've discussed so far contained just 1 section, meaning that the custom format is
applied to all number types - positive, negative and zeros.
To make a custom format for negative numbers, you'd need to include at least 2 code sections: the first will be
used for positive numbers and zeros, and the second - for negative numbers.
To show negative values in parentheses, simply include them in the second section of your format code, for
example: #.00; (#.00)
Tip. To line up positive and negative numbers at the decimal point, add an indent to the positive values
section, e.g. 0.00_); (0.00)
As you remember, the zero layout is determined by the 3rd section of the format code. So, to force zeros to
appear as dashes, type "-" in that section. For example: 0.00;(0.00);"-"
The above format code instructs Excel to display 2 decimal places for positive and negative numbers, enclose
negative numbers in parentheses, and turn zeros into dashes.
If you don't want any special formatting for positive and negative numbers, type General in the 1st and 2nd
sections: General; -General; "-"
To turn zeroes into blanks, skip the third section in the format code, and only type the ending semicolon:
General; -General; ; General
Most often, the right indent is included in a positive number format, so that Excel leaves space for the
parentheses enclosing negative numbers.
For example, to indent positive numbers and zeros from the right and text from the left, you can use the
following format code:
0.00_);(0.00); 0_);_(@
_(0.00_);_((0.00);_(0_);_(@_)
To format financial data or other types of data where it's important to distinguish between positive and
negative numbers, you can use the following format, which indents positive numbers and zeros from the right
border. Additionally, it rounds all numbers to the nearest integer and displays them with a space as a
thousand separator. Negative numbers are displayed in parentheses and in red font color:
The indent codes move the cell data by one character width. To move values from the cell edges by more than
one character width, include 2 or more consecutive indent codes in your number format. The following
screenshot demonstrates indenting cell contents by 1 and 2 characters:
[Black] [Magenta]
[Green] [Yellow]
[White] [Cyan]
[Blue] [Red]
Note. The color code must be the first item in the section.
For example, to leave the default General format for all value types, and change only the font color, use the
format code similar to this:
[Green]General;[Red]General;[Black]General;[Blue]General
Or, combine color codes with the desired number formatting, e.g. display the currency symbol, 2 decimal
places, a thousands separator, and show zeros as dashes:
For example, to include enough equality signs after a number to fill the cell, use this number format: #*=
Or, you can include leading zeros by adding *0 before any number format, e.g. *0#
This formatting technique is commonly used to change cell alignment as demonstrated in the next formatting
tip.
For example, to align numbers left in a cell, type an asterisk and a space after the number code, for example:
"#,###* " (double quotes are used only to show that an asterisk is followed by a space, you don't need them
in a real format code).
Making a step further, you could have numbers aligned left and text entries aligned right using this custom
format:
#,###* ; -#,###* ; 0* ;* @
This method is used in the built-in Excel Accounting format . If you apply the Accounting format to some cell,
then open the Format Cells dialog, switch to the Custom category and look at the Type box, you will see this
format code:
For example, to displays numbers that are less than 10 in a red font color, and numbers that are greater than
or equal to 10 in a green color, use this format code:
[Red][<10];[Green][>=10]
Additionally, you can specify the desired number format, e.g. show 2 decimal places:
[Red][<10]0.00;[Green][>=10]0.00
And here is another extremely useful, though rarely used formatting tip. If a cell displays both numbers and
text, you can make a conditional format to show a noun in a singular or plural form depending on the
number. For example:
If a cell value is greater than 1, the plural form "miles" will show up. Say, the number 3.5 will display as "3.5
miles".
Taking the example further, you can display fractions instead of decimals:
In this case, the value 3.5 will appear as "3 1/2 miles".
Tip. To apply more sophisticated conditions, use Excel's Conditional Formatting feature, which is specially
designed to handle the task.
Well, this is how you can change number format in Excel and create your own formatting. Finally, here's a
couple of tips to quickly apply your custom formats to other cells and workbooks:
A custom Excel format is stored in the workbook in which it is created and is not available in any other
workbook. To use a custom format in a new workbook, you can save the current file as a template, and then
use it as the basis for a new workbook.
To apply a custom format to other cells in a click, save it as an Excel style - just select any cell with the
required format, go to the Home tab > Styles group, and click New Cell Style….
To explore the formatting tips further, you can download a copy of the Excel Custom Number Format
workbook we used in this tutorial. I thank you for reading and hope to see you again next week!
628 comments
← Older Comments
1 excellent says:
2024-06-19 at 10:41 pm
Reply
2 ben says:
2024-06-19 at 7:03 pm
Please help on how to create custom formatting using @ with a number for using in comment
to excel modellling
Reply
Hi! Please clarify your problem or provide additional details to highlight exactly what you
need.
Reply
3 Lasse says:
2024-06-19 at 6:55 pm
Reply
Hello Lasse!
Unfortunately, I don't really understand how you can use this format code to show
percentages in a cell. To use different formats in cell depending on the value, I recommend
using conditional formatting.
Reply
Lasse says:
2024-06-20 at 8:03 am
Reply
Lasse says:
2024-06-21 at 10:15 am
Well, something is filtered out when sending the post - probably because I am not
allowed to post specific combination of signs/letters...
Reply
4 rishi says:
2024-06-17 at 8:36 am
Need cell format for showing lakhs into millions
Reply
Hi! To show a number in millions, you can use this custom format:
#,##0,," M"
Reply
Hi ~
I have successfully used the custom method to add preceding zeros to a cells in a column
containing 9 digits (SSNs). Although it displays correctly on the spreadsheet, it reverts when I
re-open the file. I have tried to convert the column to text, but the zeros still disappear after
saving and re-opening. The formula window also does not show the zeros. I can't use the
special SSN formatting because the import does not accept the hyphens between the digits.
Can you help, please?
Reply
Hi! I don't know what method you are using to add leading zeros. I think this guide will help
you solve the problem: Leading zeros in Excel: how to add, remove and hide.
I hope it’ll be helpful. If this is not what you wanted, please describe the problem in more
detail.
Reply
6 vishwa says:
2024-04-28 at 6:14 pm
Need cell format which show % and value in same cell as per section even cell value is zero.
[>=1] #,##0;[>0] 0%;0
Reply
Hi! To understand what you want to do, give an example of the source data and the
expected result.
Reply
7 megan says:
2024-04-24 at 3:18 pm
How do you add a zero. For example, i need to type 1405.5 and it come out to 14'05.5''
Reply
8 Srdjan says:
2024-04-18 at 5:10 am
Dear Sir,
is it possible, in cell which have three lines (rows) inside, to color every line in different color or
some lines to be bold some not?
Reply
Hi! You can change the format of part of the text string inside a cell either manually or by
using VBA code.
Reply
Srdjan says:
2024-04-18 at 12:01 pm
Reply
Hi! Custom formatting changes the format of the entire cell, not a part of the text in
the cell.
Reply
9 Adelina says:
2024-04-17 at 6:12 pm
Reply
Hi! To apply custom number format only for certain values, use conditional formatting.
Create a rule that applies this format only to numbers that are within the specified range.
For example: AND(A1>7200000000,A1<799999999)
The following tutorial should help: Excel Conditional Formatting tutorial with examples.
Reply
← Older Comments
Post a comment
Your comment
I have read and accept the Terms of use and Privacy Policy
Send