Excel course · Lesson 8 of 34
Number formats and custom format codes
Control how numbers, dates, percentages and currencies appear, and write custom format codes with sections, colours, thousands scaling and text.
A number format changes what a value looks like without changing the value itself. The cell holding 0.24 can appear as 0.24, 24%, 24.0% or 0.240. A cell holding 46096 can appear as 2026-03-15, 15-Mar-26 or Sunday. Understanding this split between stored value and displayed value prevents many "Excel is wrong" moments, and custom formats let you produce report-ready output without helper columns.
Built-in number formats
Select cells and use the drop-down in Home › Number › Number Format, or open Format Cells › Number (Ctrl+1, Mac: Cmd+1) for more options.
| Format | Stored value | Displayed as |
|---|---|---|
| General | 1234.5 | 1234.5 |
| Number, 2 decimals, separator | 1234.5 | 1,234.50 |
| Currency (€) | 1234.5 | €1,234.50 |
| Accounting (€) | 1234.5 | € 1,234.50 (symbol aligned at the left edge) |
| Percentage, 1 decimal | 0.0826 | 8.3% |
| Short Date | 46096 | a date in your regional format, e.g. 3/15/2026 |
| Time | 0.6875 | 4:30:00 PM |
| Fraction | 0.75 | 3/4 |
| Scientific | 1234.5 | 1.23E+03 |
| Text | 00123 | 00123 (kept as text) |
The quick buttons in Home › Number are Accounting Number Format, Percent Style (Ctrl+Shift+%), Comma Style, and Increase/Decrease Decimal. On a Mac the Percent shortcut is the same, Ctrl+Shift+%.
8% directly (Excel stores 0.08), or type 0.08 and then apply the format.Displayed value versus stored value
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Price | Qty | Line total |
| 2 | Cable | 0.502 | 2 | 1.004 |
| 3 | Adapter | 0.502 | 2 | 1.004 |
| 4 | Plug | 0.502 | 2 | 1.004 |
| 5 | Total | 3.01 |
Prices have three decimals but column D is formatted with two. Each line shows 1.00, yet the total shows 3.01.
Result: 3.01
A reader adds the visible lines, 1.00 + 1.00 + 1.00, gets 3.00, and then sees 3.01 in the total cell. Nothing is wrong with the sum: Excel adds the stored values 1.004 + 1.004 + 1.004 = 3.012 and displays that rounded to 3.01. When displayed amounts must add up exactly, as on an invoice, round each stored value with ROUND, for example =ROUND(B2*C2,2), instead of relying on the format.
Custom number formats
When no built-in format fits, write your own. Open Format Cells › Number › Custom, type a code in the Type box and watch the Sample preview. The most useful code characters are:
| Code | Meaning | Example code | 1234.5 shows as |
|---|---|---|---|
| 0 | A digit, shows zeros | 0.00 | 1234.50 |
| # | A digit, hides leading/trailing zeros | #,##0 | 1,235 |
| ? | A digit, pads with a space so decimals line up | 0.0?? | 1234.5 |
| , | Thousands separator; at the end it divides by 1,000 | #,##0.0,"k" | 1.2k |
| "text" | Literal text | 0" pcs" | 1235 pcs |
| [Red] | Colour | 0;[Red]-0 | 1235 |
| @ | Placeholder for text in the text section | "Code: "@ | (for text values) |
The four sections
A custom format can have up to four sections separated by semicolons: positive ; negative ; zero ; text. If you give only one section, it applies to all numbers. With two sections the first is used for positives and zeros and the second for negatives.
#,##0.00;[Red]-#,##0.00;"–";@| Stored value | Displayed with the code above |
|---|---|
| 1500 | 1,500.00 |
| -320.5 | -320.50 (in red) |
| 0 | – |
| n/a | n/a |
Scaling to thousands and millions
A comma at the end of the code divides the display by 1,000; two commas divide by a million. This is ideal for dashboards where 1,482,300 is too much detail.
| Code | 1482300 shows as |
|---|---|
| #,##0,"K" | 1,482K |
| 0.0,,"M" | 1.5M |
| €#,##0.0,," m" | €1.5 m |
Adding units and leading zeros
00000shows 123 as00123. The value stays a number (123), so it still sorts and calculates, unlike a typed'00123.0" kg"shows 25 as25 kg, and the cell still holds 25, so =SUM still works. Typing25 kgwould create text that formulas ignore.+0%;-0%;0%shows growth with an explicit plus sign:+12%,-3%,0%.;;;(three semicolons, nothing else) hides the value completely. The formula bar still reveals it.
Conditions in formats
Instead of positive/negative, sections can use conditions in square brackets. [>=1000000]0.0,,"M";[>=1000]0,"K";0 shows 2,500,000 as 2.5M, 48,000 as 48K and 950 as 950. Only two conditions are allowed; for more complex rules use Conditional formatting, including formula-based rules.
Date and time codes
| Code | Shows 2026-03-15 14:05 as |
|---|---|
| yyyy-mm-dd | 2026-03-15 |
| dd-mmm-yy | 15-Mar-26 |
| d mmmm yyyy | 15 March 2026 |
| ddd | Sun |
| dddd | Sunday |
| mmm yyyy | Mar 2026 |
| hh:mm | 14:05 |
| h:mm AM/PM | 2:05 PM |
m means month, except directly after h or before s, where it means minutes. For durations longer than 24 hours, put the hour code in square brackets: [h]:mm. A timesheet total of 1.5 days shows as 12:00 with h:mm but correctly as 36:00 with [h]:mm.
| A | B | |
|---|---|---|
| 1 | Day | Hours |
| 2 | Mon | 8:30 |
| 3 | Tue | 9:15 |
| 4 | Wed | 7:45 |
| 5 | Thu | 8:00 |
| 6 | Total | 33:30 |
B6 is formatted [h]:mm. With the plain h:mm format it would show 9:30.
Result: 33:30
=TEXT(B6,"[h]:mm")&" hours". The codes for month and day names follow the language of your Excel installation.Accounting versus Currency
Both add a currency symbol. Currency puts the symbol right next to the number and lets you choose how negatives appear. Accounting aligns the symbols in a column, shows negatives in parentheses in many locales, and displays zero as a dash. Accounting is common in financial statements; Currency in price lists.
Text that looks like a number
Numbers imported from other systems often arrive as text: they are left-aligned and show a green triangle. Formatting the cell as Number does not fix this, because the format only affects display. To convert, select the cells, click the warning icon and choose Convert to Number, or use Data › Data Tools › Text to Columns › Finish, or a formula like =VALUE(A2). More in Text cleanup: TRIM, CLEAN, TEXTSPLIT, Flash Fill and Text to Columns.
. and , in English versions.Check yourself
1. A cell contains 0.075 and is formatted as Percentage with 1 decimal. What does it show?
Percentage format displays the value multiplied by 100.
2. Which custom format shows 2,450,000 as 2.5M?
Two trailing commas divide the display by one million.
3. A timesheet total of 41 hours shows as 17:00. What format fixes it?
Square brackets around h let hours run past 24.
4. What does the format 0;[Red]-0;"–" display for a zero?
The third section is used for zero values.
5. Cells imported from a system contain numbers stored as text. You apply the Number format. What happens?
Formats change display only. Use Convert to Number, Text to Columns or VALUE.