Number Format Codes: Text and Spacing
Number Format Codes: Text and Spacing
z 0 (zero) displays insignificant zeros if a number has fewer digits than there are zeros in the format.
z ? adds spaces for insignificant zeros on either side of the decimal point so that decimal points align when formatted with a
fixed-width font, such as Courier New. You can also use ? for fractions that have varying numbers of digits.
Thousands separator To display a comma as a thousands separator or to scale a number by a multiple of one thousand,
include a comma in the number format.
12000 as 12 #,
Color To set the color for a section of the format, type the name of one of the following eight colors in square brackets in the
section. The color code must be the first item in the section.
[Black] [Blue]
[Cyan] [Green]
[Magenta] [Red]
[White] [Yellow]
Conditions To set number formats that will be applied only if a number meets a condition you specify, enclose the condition in
square brackets. The condition consists of a comparison operator (comparison operator: A sign that is used in comparison criteria
to compare two values. Operators include: = Equal to, > Greater than, < Less than, >= Greater than or equal to, <= Less than or
equal to, <> Not equal to.) and a value. For example, the following format displays numbers less than or equal to 100 in a red
font and numbers greater than 100 in a blue font.
[Red][<=100];[Blue][>100]
To apply conditional formats (conditional format: A format, such as cell shading or font color, that Excel automatically applies to
cells if a specified condition is true.) to cells — for example, color shading that depends on the value of a cell — use the
Conditional Formatting command on the Format menu.
Currency, percentages, and scientific notation
Currency symbols To enter one of the following currency symbols in a number format, turn on NUM LOCK and use the numeric
keypad to enter the ANSI code for the symbol.
¢ 0162
£ 0163
¥ 0165
0128
Note Custom formats are saved with the workbook. To have Microsoft Excel always use a specific currency symbol, change the
currency symbol selected in Regional Settings in Control Panel before you start Excel.
Percentage To display numbers as a percentage of 100, include the percent sign (%) in the number format. For example, a
number such as .08 appears as 8%; 2.8 appears as 280%.
Scientific notation To display numbers in scientific format, use "E-," "E+," "e-," or "e+" exponent codes in a section. If a
format contains a zero (0) or number sign(# ) to the right of an exponent code, Excel displays the number in scientific format and
inserts an "E" or "e". The number of zeros or number signs to the right of a code determines the number of digits in the exponent.
"E-" or "e-" places a minus sign by negative exponents. "E+" or "e+" places a minus sign by negative exponents and a plus sign
by positive exponents.
Dates and times
Days, months, and years If you use "m" immediately after the "h" or "hh" code or immediately before the "ss" code, Microsoft
Excel displays minutes instead of the month.
Months as 1–12 m
Months as 01–12 mm
Days as 1–31 d
Days as 01–31 dd
Years as 00–99 yy
Hours as 0–23 H
Hours as 00–23 hh
Minutes as 0–59 m
Minutes as 00–59 mm
Seconds as 0–59 s
Seconds as 00–59 ss
Hours as 4 AM h AM/PM
AM and PM If the format contains an AM or PM, the hour is based on the 12-hour clock, where "AM" or "A" indicates times from
midnight until noon and "PM" or "P" indicates times from noon until midnight. Otherwise, the hour is based on the 24-hour clock.
The "m" or "mm" code must appear immediately after the "h" or "hh" code or immediately before the "ss" code; otherwise,
Microsoft Excel displays the month instead of minutes.