Excel has many built-in formats. You can select standard number formats such as General, Number, Currency, Accounting, Short Date, Long Date, Time, Percentage, Fraction, Scientific, Text on the home tab of the ribbon using the Number Format menu.
If you cannot find the right format, you can create a custom number format.
N/B: A custom number format is stored in the workbook where you create it. If you copy a value with a custom number format to another workbook, it will also be available in that workbook.
Important ! As you enter data, Excel will sometimes change number formats automatically. For example if you enter a valid date, Excel will change to “Date” format. If you enter a percentage like 5%, Excel will change to Percentage, and so on.
- Number format shortcuts
- Custom number format
- Understanding Structure and Reference
- Number formats for TEXT
- Number formats for DATES
- Number formats for TIME
- Number formats for ELAPSED TIME
- Number formats for COLORS
- Formula number formats
- Telephone numbers
Shortcuts for number formats
Excel provides a number of keyboard shortcuts for some common formats:
|General format||Ctrl Shift ~|
|Currency format||Ctrl Shift $|
|Percentage format||Ctrl Shift %|
|Scientific format||Ctrl Shift ^|
|Date format||Ctrl Shift #|
|Time format||Ctrl Shift @|
|Custom formats||Control + 1|
Custom number format
To create custom number format follow this simple 4-step process:
- Select cell(s) with values you want to format
- Control + 1 > Numbers > Custom
- Enter codes and watch preview area to see result
- Press OK to save and apply
Tip: if you want base your custom format on an existing format, first apply the base format, then click the “Custom” category and edit codes as you like.
How to edit a custom number format
You can’t really edit a custom number format per se. When you change an existing custom number format, a new format is created and will appear in the list in the Custom category. You can use the Delete button to delete custom formats you no longer need.
Warning: there is no “undo” after deleting a custom number format!
Understanding Structure and Reference
Excel custom number formats have a specific structure. Each number format can have up to four sections, separated with semi-colons as follows:
This structure can make custom number formats look overwhelmingly complex. To read a custom number format, learn to spot the semi-colons and mentally parse the code into these sections:
- Positive values
- Negative values
- Zero values
- Text values
Not all sections required
Although a number format can include up to four sections, only one section is required. By default, the first section applies to positive numbers, the second section applies to negative numbers, the third section applies to zero values, and the forth section applies to text.
- When only one format is provided, Excel will use that format for all values.
- If you provide a number format with just two sections, the first section is used for positive numbers and zeros, and the second section is used for negative numbers.
- To skip a section, include a semi-colon in the proper location, but don’t specify a format code.
Characters that display natively
Some characters appear normally in a number format, while others require special handling. The following characters can be be used without any special handling:
|<>||Less than, greater than|
Some characters won’t work correctly in a custom number format without being escaped. For example, the asterisk (*), hash (#), and percent (%) characters can’t be used directly in a custom number format – they won’t appear in the result. The escape character in custom number formats is the backslash (\). By placing the backslash before the character, you can use them in custom number formats:
Placeholders for numbers
Certain characters have special meaning in custom number format codes. The following characters are key building blocks:
|Display insignificant zeros|
|#||Display significant digits|
|?||Display aligned decimals|
Zero (0) is used to force the display of insignificant zeros when a number has fewer digits than than zeros in the format. For example, the custom format 0.00 will display zero as 0.00, 1.1 as 1.10 and .5 as 0.50.
Pound sign (#) is a placeholder for optional digits. When a number has fewer digits than # symbols in the format, nothing will be displayed. For example, the custom format #.## will display 1.15 as 1.15 and 1.1 as 1.1.
Question mark (?) is used to align digits. When a question mark occupies a place not needed in a number, a space will be added to maintain visual alignment.
Period (.) is a placeholder for the decimal point in a number. When a period is used in a custom number format, it will always be displayed, regardless of whether the number contains decimal values.
Comma (,) is a placeholder for the thousands separators in the number being displayed. It can be used to define the behavior of digits in relation to the thousands or millions digits.
Asterisk (*) is used to repeat characters. The character immediately following an asterisk will be repeated to fill remaining space in a cell.
Underscore (_) is used to add space in a number format. The character immediately following an underscore character controls how much space to add. A common use of the underscore character is to add space to align positive and negative values when a number format is adding parentheses to negative numbers only. For example, the number format “0_);(0)” is adding a bit of space to the right of positive numbers so that they stay aligned with negative numbers, which are enclosed in parentheses.
It’s important to understand the Excel will perform “visual rounding” with all custom number formats. When a number has more digits than placeholders on the right side of the decimal point, the number is rounded to the number of placeholders. When a number has more digits than placeholders on the left side of the decimal point, extra digits are displayed. This is a visual effect only; actual values are not modified.
Number formats for TEXT
To display both text along with numbers, enclose the text in double quotes (“”). You can use this approach to append or prepend text strings in a custom number format, as shown in the table below.
|10||General” units”||10 units|
|10||0.0″ units”||10.0 units|
|5.5||0.0″ feet”||5.5 feet|
|30000||0″ feet”||30000 feet|
|95.2||“Score: “0.0||Score: 95.2|
|1-Jun||“Date: “mmmm d||Date: June 1|
Number formats for DATES
Dates in Excel are just numbers, so you can use custom number formats to change the way they display. Excel many specific codes you can use to display components of a date in different ways. The screen below shows how Excel displays the date in D5, September 3, 2018, with a variety of custom number formats:
Number formats for TIME
Times in Excel are fractional parts of a day. For example, 12:00 PM is 0.5, and 6:00 PM is 0.75. You can use the following codes in custom time formats to display components of a time in different ways. The screen below shows how Excel displays the time in D5, 9:35:07 AM, with a variety of custom number formats:
Note: m and mm can’t be used alone in a custom number format since they conflict with the month number code in date format codes.
Number formats for ELAPSED TIME
Elapsed time is a special case and needs special handling. By using square brackets, Excel provides a special way to display elapsed hours, minutes, and seconds. The following screen shows how Excel displays elapsed time based on the value in D5, which represents 1.25 days:
Number formats for COLORS
Excel provides basic support for colors in custom number formats. The following 8 colors can be specified by name in a number format: [black] [white] [red][green] [blue] [yellow] [magenta] [cyan]. Color names must appear in brackets.
Colors by index
In addition to color names, it’s also possible to specify colors by an index number (Color1,Color2,Color3, etc.) The examples below are using the custom number format: [ColorX]0″▲▼”, where X is a number between 1-56:
[Color1]0"▲▼" // black [Color2]0"▲▼" // white [Color3]0"▲▼" // red [Color4]0"▲▼" // green etc.
The triangle symbols have been added only to make the colors easier to see. The first image shows all 56 colors on a standard white background. The second image shows the same colors on a gray background. Note the first 8 colors shown correspond to the named color list above.
Apply number formats in a formula
Although most number formats are applied directly to cells in a worksheet, you can also apply number formats inside a formula with the TEXT function. For example, with a valid date in A1, the following formula will display the month name only:
The result of the TEXT function is always text, so you are free to concatenate the result of TEXT to other strings:
="The contract expires in "&TEXT(A1,"mmmm")
The screen below shows the number formats in column C being applied to numbers in column B using the TEXT function:
Custom number formats also up to two conditions, which are written in square brackets like [>100] or [<=100]. When you use conditionals in custom number formats, you override the standard [postive];[negative];[zero];[text] structure. For example, to display values below 100 in red, you can use:
To display values greater than or equal to 100 in blue, you can extend the format like this:
To apply more than two conditions, or to change other cell attributes, like fill color, etc. you’ll need to switch to Conditional Formatting, which can can apply formatting with much more power and flexibility using formulas.
Plural text labels
You can use conditionals to add an “s” to labels greater than zero with a custom format like this:
[=1]0″ day”;0″ days”
Custom number formats can also be used for telephone numbers, as shown in the screen below:
Notice the third and forth examples use a conditional format to check for numbers that contain an area code. If you have data that contains phone numbers with hard-coded punctuation (parentheses, hyphens, etc.) you will need to clean the telephone numbers first so that they only contain numbers.
Hide all content
You can actually use a custom number format to hide all content in a cell. The code is simply three semi-colons and nothing else ;;;
To reveal the content again, you can use the keyboard shortcut Control + Shift + ~, which applies the General format.