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.

Beginner 16 min read

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.

FormatStored valueDisplayed as
General1234.51234.5
Number, 2 decimals, separator1234.51,234.50
Currency (€)1234.5€1,234.50
Accounting (€)1234.5€ 1,234.50 (symbol aligned at the left edge)
Percentage, 1 decimal0.08268.3%
Short Date46096a date in your regional format, e.g. 3/15/2026
Time0.68754:30:00 PM
Fraction0.753/4
Scientific1234.51.23E+03
Text0012300123 (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+%.

Watch out. Percent Style multiplies the display by 100. If you type 8 into a cell and then apply %, you get 800%. Either type 8% directly (Excel stores 0.08), or type 0.08 and then apply the format.

Displayed value versus stored value

D5fx=SUM(D2:D4)
ABCD
1ItemPriceQtyLine total
2Cable0.50221.004
3Adapter0.50221.004
4Plug0.50221.004
5Total3.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:

CodeMeaningExample code1234.5 shows as
0A digit, shows zeros0.001234.50
#A digit, hides leading/trailing zeros#,##01,235
?A digit, pads with a space so decimals line up0.0??1234.5
,Thousands separator; at the end it divides by 1,000#,##0.0,"k"1.2k
"text"Literal text0" pcs"1235 pcs
[Red]Colour0;[Red]-01235
@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.

Formula
#,##0.00;[Red]-#,##0.00;"–";@
Positives with separator, negatives in red with a minus, zeros shown as a dash, text unchanged.
Stored valueDisplayed with the code above
15001,500.00
-320.5-320.50 (in red)
0–
n/an/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.

Code1482300 shows as
#,##0,"K"1,482K
0.0,,"M"1.5M
€#,##0.0,," m"€1.5 m

Adding units and leading zeros

  • 00000 shows 123 as 00123. The value stays a number (123), so it still sorts and calculates, unlike a typed '00123.
  • 0" kg" shows 25 as 25 kg, and the cell still holds 25, so =SUM still works. Typing 25 kg would 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

CodeShows 2026-03-15 14:05 as
yyyy-mm-dd2026-03-15
dd-mmm-yy15-Mar-26
d mmmm yyyy15 March 2026
dddSun
ddddSunday
mmm yyyyMar 2026
hh:mm14:05
h:mm AM/PM2: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.

B6fx=SUM(B2:B5)
AB
1DayHours
2Mon8:30
3Tue9:15
4Wed7:45
5Thu8:00
6Total33:30

B6 is formatted [h]:mm. With the plain h:mm format it would show 9:30.

Result: 33:30

Tip. The TEXT function uses the same codes inside formulas: =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.

Note. Custom formats work the same in Excel for Windows, Mac and the web. Formats are stored in the workbook, so custom codes travel with the file. Regional settings change the decimal and thousands symbols displayed, but codes are typed with . and , in English versions.

Check yourself

1. A cell contains 0.075 and is formatted as Percentage with 1 decimal. What does it show?

2. Which custom format shows 2,450,000 as 2.5M?

3. A timesheet total of 41 hours shows as 17:00. What format fixes it?

4. What does the format 0;[Red]-0;"–" display for a zero?

5. Cells imported from a system contain numbers stored as text. You apply the Number format. What happens?

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB