Features of !SEMTools
↑ Навигация по задачам в Excel и возможностям надстройки !SEMTools ↑

TEXT

TEXT function examples in Excel
Examples of the TEXT function in Excel
Function CategoryText
VolatilityNon-volatile
Related Functions

What does the TEXT function do?

The TEXT function converts a number to text in a specified number format.

This can include dates, times and their fragments, financial units, percentages.

Conversion to custom user formats is also possible, which can be created based on existing ones.

The complete list of formats can be found using the Format Cells procedure. This procedure can be accessed through the context menu, which can be opened by right-clicking any cell.

Format Cells dialog in Excel

And then select the desired type from the list of number formats.

Number format selection in Excel

TEXT function syntax

=TEXT(number, format)
TEXT with different formats
C2=TEXT(A2,"mm/dd/yyyy")
ABC
1ValueFormatResult
246317"mm/dd/yyyy"10/22/2026=TEXT(A2,"mm/dd/yyyy")
346317"dddd"Thursday=TEXT(A3,"dddd")
41234.5"$#,##0.00"$1,234.50=TEXT(A4,"$#,##0.00")
50.257"0.0%"25.7%=TEXT(A5,"0.0%")
60.6041667"h:mm AM/PM"2:30 PM=TEXT(A6,"h:mm AM/PM")
742"00000"00042=TEXT(A7,"00000")

The format is a text string in quotes, the same codes as in Format Cells → Custom. The result is text: it’s left-aligned and can’t be summed directly. Date codes depend on the Excel language — in a non-English Excel, "yyyy" may need to be written differently.

TEXT: result and input format

No special formatting required.

Logical values are not converted to their numerical equivalents but become text.

Numbers formatted as text are treated as numbers.

TEXT formula examples

Example 1

To ensure correct sorting of numbers in text format, it may be necessary to add leading zeros to numbers to equalize their length.

The specialist used the TEXT formula with a custom format.

Example 1: leading zeros
B2=TEXT(A2,"00000")
ABC
1Number5 digitsAs text: sorts right
2700007=TEXT(A2,"00000")ID-00007="ID-"&TEXT(A2,"00000")
34500045=TEXT(A3,"00000")ID-00045
412300123=TEXT(A4,"00000")ID-00123
5102401024=TEXT(A5,"00000")ID-01024

Each 0 in the format is a required digit, so short numbers are padded with zeros. As text, ID-00007 sorts before ID-00045; without padding, ID-7 would come after ID-45.

Adding leading zeros to numbers for uniform length
Adding leading zeros to numbers to ensure uniform length

Example 2

Customer phone numbers are stored in the database in normalized form, without any separators or symbols. For convenient manual calling from the database, the sales manager used a custom phone number format in the TEXT function.

Example 2: phone number format
B2=TEXT(A2,"+0 (000) 000-0000")
AB
1Phone (number)Readable
215551234567+1 (555) 123-4567=TEXT(A2,"+0 (000) 000-0000")
312025550143+1 (202) 555-0143=TEXT(A3,"+0 (000) 000-0000")
4447700900123+44 (770) 090-0123=TEXT(A4,"+0 (000) 000-0000")

Format codes fill digits from the right: the last 10 go into the (000) 000-0000 mask, and everything left over goes to the leading 0, so a 2-digit country code (44) works too.

Formatting phone numbers with TEXT function
Converting phone numbers to a readable format using the TEXT function in Excel

Like the article? Help its author! Buy !SEMTools, it has lots of useful instruments to process text data.