Sub topic 15
Formatting values inside text with TEXT
This chapter assumes you can write a basic formula, and that you know a number format changes how a value looks, not what is stored. Here you will use the TEXT function to apply a format code inside a formula. That lets you build labels and sentences that contain formatted numbers and dates.
Why TEXT is needed
When you join a number to text with &, Excel uses the raw stored value. It ignores the cell's number format. If A1 holds the date 2026-11-27 formatted as a date, the formula ="Due: "&A1 returns Due: 46353. The serial number appears because the join works with the stored value.
TEXT(value, format_text) fixes this. It converts a value to text, using the format code you give it.
The syntax
The first argument is the value or cell. The second is a format code in quotation marks. These are the same codes you write in the Custom category of Format Cells.
=TEXT(A1,"yyyy-mm-dd")This converts the date in A1 to text in ISO order. The result is text, not a date.
Common patterns
Here is a join that shows a total with thousands separators and two decimals. Suppose B2 holds 1234.5.
="Total: "&TEXT(B2,"#,##0.00")The result is Total: 1,234.50.
Other useful codes:
| Formula | Result for the sample value |
|---|---|
| `=TEXT(0.256,"0.0%")` | 25.6% |
| `=TEXT(42,"00000")` | 00042 |
| `=TEXT(1234567,"0.0,,")&"M"` | 1.2M |
| `=TEXT(A1,"dddd")` | The weekday name, such as Friday |
Common errors
- The result is text. You cannot add, sum, or chart it as a number. Keep the original cell for calculations and use TEXT only for display.
- Missing quotation marks. The format code must be a quoted string.
=TEXT(A1,yyyy)fails. - Rounding. TEXT rounds the displayed digits only in the string. The source cell is unchanged. Use
=ROUND(A1,2)if you need the stored value to change. - Wrong codes for your language. Codes such as
yyyyandddcan depend on the language of the Excel installation. A German installation expectsJJJJfor the year, so a workbook shared across languages may show errors or wrong output. - Colors and fill do not carry over. The text result has no color. A code like
[Red]has no effect on the cell's font color in the result.
Choosing between a format and TEXT
Use a cell number format when the cell itself is the final result and other formulas may use it. Use TEXT when the value must sit inside a sentence, a chart label, or a file name.
Exercise
Cell A1 holds the date 2024-01-01 and B1 holds 0.075. Write one formula that returns the text "Rate on 2024-01-01: 7.5%".
Show answer
="Rate on "&TEXT(A1,"yyyy-mm-dd")&": "&TEXT(B1,"0.0%")
Exercise
A formula ="Sales: "&C1 shows Sales: 1234567.891 and you want Sales: 1,234,567.89. What change fixes it, and can you still sum the result?
Show answer
Use ="Sales: "&TEXT(C1,"#,##0.00"). The result is text, so you cannot sum it. Sum C1 instead.