Custom Formatting Complete Guide
Custom Formatting Complete Guide
Section1
Underneath the pre-defined number formats for common items like currency and
Is not the same as:
percentage, there is a category called Custom. The format types in this section are different from the pre-set
options. They are filled with symbols and codes:
Section1;Section1;Section1;Section1
Look at the examples below to see examples of the difference…
Now that we understand what a number format code is, what can we do with it?
[Color Name]
Just choose the section that corresponds to the part of the number line you want to change color, and provide the
color in brackets. The color options are as follows (the background is gray for contrast in the table, but
A number format code is entered into the Type field in the Custom category. These codes are the key to
creating any custom number format in Excel. First, however, we need to understand how they work…
backgrounds are not affected by the number format code):
Understanding the Number Format Codes
As an example, we can provide a separate color code for each part of a number format code:
[Red]General;[Blue]General;[Magenta]General;[Cyan]General Results in the following output:
The General message just tells Excel to represent the numbers as entered by the user. The output of this number
format code looks like this:
\@General
Results in the following output:
Note that the minus sign still precedes the negative number. Also note that the Text value is not affected
by the @ symbol addition.
Importantly, this is different from the result if we expanded our format guideline to each section of the
number format code:
Excel will also accept most other non-mathematical symbols, such a non-dollar currency symbols,
\@General;\@General;\@General;\@General
copyright/trademark symbols, and Greek letters. These symbols are not available on most standard
Results in the following output: keyboards, but they can be entered by holding down the ALT key while typing in a four-digit number.
Some of the most useful ones are below:
Note that the minus sign is gone from the negative number and the Text value now receives the @
symbol.
Text Strings
To add an entire text string to a number (like adding “units” to the end of a number), we surround the
text string in quotation marks (” “). The number format code:
A full list of ANSI character codes can be found on Wikipedia here.
General" units"
Changing Decimal Places, Significant Digits, and Commas Here is an example of the pound sign code in action. The following examples are using this number
format code:
Adding symbols and colors is useful, but most of the work you’ll likely need to do with custom number
formats is change the way Excel displays the numbers it stores. Number format codes use a set of #.##
symbols to represent how the data should appear in the cell. Here is a summary of the symbols:
Period (.)
The period in the number format code represents the location of the decimal point in the number being
Let’s review them each in turn…
displayed. When paired with the comma code, it can show numbers in thousands or millions,
changing 1,200 to 1.2, for example. It is similar to the text format codes above in that it is always
Zero (0) displayed when it is part of the number code, even when number being displayed does not straddle the
Zeros in the number format code represent a forced digit. That means that whether or not the digit is decimal point. See the comma, pound sign and question mark examples above for useful illustrations of
relevant to the value, it will be shown. A great example of this is the standard dollars and cents notation the period in use.
that is used to represent prices in the United States: $0.00. Even if there are no extra cents in the
amount, the two zeroes are still shown in the notation. Comma (,)
Here is an example of the zero code in action. The following examples are using this number format The comma in the number format code represents the thousands separators in the number being
code: displayed. It allows you to describe the behavior of digits in relation to the thousands or millions digits.
Here is an example of the comma code in action. The following examples are using this number format
0.00
code:
$??,???.00
*=0.##
# ###/###
Produces a more readable fraction remainder that can be justified or centered in the cell:
Improper Fractions
If you’d rather bundle the whole number portion of a value into the fraction itself, you can specify as
We’ll examine each in detail… much in the number format code.
Using pound sign notation, the following number format code:
Fractions (/)
Fractions are special, since they require a change in units. The number 0.23 is represented as 23/100, ###/###
but 0.25 can be simplified t0 1/4 or shown as 25/100. Similarly, 1.25 can be shown as 1 1/4 or the Produces an improper fraction with up to three digits:
improper fraction 5/4. Which way Excel displays the number depends on how you construct the number
format code.
Fractions effectively round values to the nearest possible fraction. They also take the guidelines of the
pound sign and question mark symbols they are paired with.
The result is a rounded fraction remainder that goes to the nearest number of 15ths.
Percentages (%)
The alignment of the fraction bar is preserved regardless of the number of digits in use. If we limit the
Much like fractions, percentages are controlled by the number format codes that accompany them. A
number of digits on each side of the fraction to 2, Excel will round the number to the nearest fraction
basic percentage can be achieved with a pound sign symbol in the number format code:
value. The following number code format:
#%
Results in the following output:
Note that in this case, the decimal and exponent are both constrained to 2 significant digits, regardless of
You can also specify fractional percentages, as shown with this number format code: whether they are necessary. The trade-off is, it keeps the output far more consistent, with a predictable
string length.
# #/#%
Results in single-digit fractions in the percentages where needed: Dates and Times
Dates and times in Excel are a special case. For a detailed discussion of how Excel uses them, please
review the Definitive Guide to Using Dates and Times in Excel. The number format codes work
identically to the format_text input for the TEXT command, and they can be reviewed here.
Finally, as always, you can specify the number of significant digits with decimal places:
#.0%
Results in a 10th place aligned decimal:
#E+#
You can also achieve more consistent notation with zeros. The following examples are using this number
format code:
0.00E+00