TEXT function

The TEXT function lets you change the way a number appears by applying formatting to it with format codes. It's useful in situations where you want to display numbers in a more readable format, or you want to combine numbers with text or symbols.

Note: The TEXT function will convert numbers to text, which may make it difficult to reference in later calculations. It’s best to keep your original value in one cell, then use the TEXT function in another cell. Then, if you need to build other formulas, always reference the original value and not the TEXT function result.


TEXT(value, format_text)

The TEXT function syntax has the following arguments:

Argument Name



A numeric value that you want to be converted into text.


A text string that defines the formatting that you want to be applied to the supplied value.


In its simplest form, the TEXT function says:

  • =TEXT(Value you want to format, "Format code you want to apply")

Here are some popular examples, which you can copy directly into Excel to experiment with on your own. Notice the format codes within quotation marks.




Currency with a thousands separator and 2 decimals, like $1,234.57. Note that Excel rounds the value to 2 decimal places.


Today’s date in MM/DD/YY format, like 03/14/12


Today’s day of the week, like Monday


Current time, like 1:29 PM


Percentage, like 28.5%

=TEXT(4.34 ,"# ?/?")

Fraction, like 4 1/3

=TRIM(TEXT(0.34,"# ?/?"))

Fraction, like 1/3. Note this uses the TRIM function to remove the leading space with a decimal value.


Scientific notation, like 1.22E+07

=TEXT(1234567898,"[<=9999999]###-####;(###) ###-####")

Special (Phone number), like (123) 456-7898


Add leading zeros (0), like 0001234

=TEXT(123456,"##0° 00' 00''")

Custom - Latitude/Longitude

Note: Although you can use the TEXT function to change formatting, it’s not the only way. You can change the format without a formula by pressing CTRL+1 (or Image of the MAC Command button icon +1 on the Mac), then pick the format you want from the Format Cells > Number dialog.

Download our examples

You can download an example workbook with all of the TEXT function examples you'll find in this article, plus some extras. You can follow along, or create your own TEXT function format codes.

Download Excel TEXT function examples

Other format codes that are available

You can use the Format Cells dialog to find the other available format codes:

  1. Press Ctrl+1 ( Image of the MAC Command button icon +1 on the Mac) to bring up the Format Cells dialog.

  2. Select the format you want from the Number tab.

  3. Select the Custom option,

  4. The format code you want is now shown in the Type box. In this case, select everything from the Type box except the semicolon (;) and @ symbol. In the example below, we selected and copied just mm/dd/yy.

  5. Press Ctrl+C to copy the format code, then press Cancel to dismiss the Format Cells dialog.

  6. Now, all you need to do is press Ctrl+V to paste the format code into your TEXT formula, like: =TEXT(B2,"mm/dd/yy"). Make sure that you paste the format code within quotes ("format code"), otherwise Excel will throw an error message.

Example of using the Format > Cells > Number > Custom dialog to have Excel create format strings for you.

Format codes by category

Following are some examples of how you can apply different number formats to your values by using the Format Cells dialog, then use the Custom option to copy those format codes to your TEXT function.

Why does Excel delete my leading 0’s?

Excel is trained to look for numbers being entered in cells, not numbers that look like text, like part numbers or SKU's. To retain leading zeros, format the input range as Text before you paste or enter values. Select the column, or range where you'll be putting the values, then use CTRL+1 to bring up the Format > Cells dialog and on the Number tab select Text. Now Excel will keep your leading 0's.

If you’ve already entered data and Excel has removed your leading 0's, you can use the TEXT function to add them back. You can reference the top cell with the values and use =TEXT(value,"00000"), where the number of 0’s in the formula represents the total number of characters you want, then copy and paste to the rest of your range.

Examples of using TEXT to format leading zeros.  =TEXT(A2,"00000")

If for some reason you need to convert text values back to numbers you can multiply by 1, like =D4*1, or use the double-unary operator (--), like =--D4.

Excel separates thousands by commas if the format contains a comma (,) that is enclosed by number signs (#) or by zeros. For example, if the format string is "#,###", Excel displays the number 12200000 as 12,200,000.

A comma that follows a digit placeholder scales the number by 1,000. For example, if the format string is "#,###.0,", Excel displays the number 12200000 as 12,200.0.

Examples of the TEXT function using the Thousands separator

Notes: The thousands separator is dependent on your regional settings. In the US it's a comma, but in other locales it might be a period (.).

The thousands separator is available for the number, currency and accounting formats.

Following are examples of standard number (thousands separator and decimals only), currency and accounting formats. Currency format allows you to insert the currency symbol of your choice and aligns it next to your value, while accounting format will align the currency symbol to the left of the cell and the value to the right. Note the difference between the currency and accounting format codes below, where accounting uses an asterisk (*) to create separation between the symbol and the value.

Examples of the TEXT function with Number, Currency and Accounting formats

To find the format code for a currency symbol, first press Ctrl+1 (or Image of the MAC Command button icon +1 on the Mac), select the format you want, then choose a symbol from the Symbol drop-down:

Currency Symbol selection from the Format Cells dialog

Then click Custom on the left from the Category section, and copy the format code, including the currency symbol.

TEXT function - Custom currency with symbol

Note: The TEXT function does not support color formatting, so if you copy a number format code from the Format Cells dialog that includes a color, like this: $#,##0.00_);[Red]($#,##0.00), the TEXT function will accept the format code, but it won't display the color.

You can alter the way a date displays by using a mix of "M" for month, "D" for days, and "Y" for years.

Month, Day and Year format codes

Format codes in the TEXT function aren't case sensitive, so you can use either "M" or "m", "D" or "d", "Y" or "y".

You can alter the way time displays by using a mix of "H" for hours, "M" for minutes, or "S" for seconds, and "AM/PM" for a 12-hour clock.

Time formats for hours, minutes and seconds

If you leave out the "AM/PM" or "A/P", then time will display based on a 24-hour clock.

Format codes in the TEXT function aren't case sensitive, so you can use either "H" or "h", "M" or "m", "S" or "s", "AM/PM" or "am/pm".

You can alter the way decimal values display with percentage (%) formats.

Format codes for Percent

You can alter the way decimal values display with fraction (?/?) formats.

Format codes for Fractions

Scientific notation is a way of displaying numbers in terms of a decimal between 1 and 10, multiplied by a power of 10. It is often used to shorten the way that large numbers display.

Format codes for Scientific notation

Excel provides 4 special formats:

  • Zip Code - "00000"

  • Zip Code + 4 - "00000-0000"

  • Phone Number - "[<=9999999]###-####;(###) ###-####"

  • Social Security Number - "000-00-0000"

Special formats for the TEXT function

Special formats will be different depending on locale, but if there aren't any special formats for your locale, or if these don't meet your needs then you can create your own through the Format Cells > Custom dialog.

Common scenario

The TEXT function is rarely used by itself, and is most often used in conjunction with something else. Let’s say you want to combine text and a number value, like “Report Printed on: 03/14/12”, or “Weekly Revenue: $66,348.72”. You could type that into Excel manually, but that defeats the purpose of having Excel do it for you. Unfortunately, when you combine text and formatted numbers, like dates, times, currency, etc., Excel doesn’t know how you want to display them, so it drops the number formatting. This is where the TEXT function is invaluable, because it allows you to force Excel to format the values the way you want by using a format code, like "MM/DD/YY" for date format.

In the following example, you’ll see what happens if you try to join text and a number without using the TEXT function. In this case, we’re using the ampersand (&) to concatenate a text string, a space (" "), and a value with =A2&" "&B2.

Example of joining text without the TEXT function

As you can see, Excel removed the formatting from the date in cell B2. In the next example, you'll see how the TEXT function lets you apply the format you want.

Example of joining text with the TEXT function

Our updated formula is:

  • Cell C2:=A2&" "&TEXT(B2,"mm/dd/yy") - Date format

Frequently Asked Questions

Unfortunately, you can’t do that with the TEXT function, you need to use Visual Basic for Applications (VBA) code. The following link has a method: How to convert a numeric value into English words in Excel

This is called Scientific Notation, and Excel will automatically convert numbers longer than 12 digits if a cell(s) is formatted as General, and 15 digits if a cell(s) is formatted as a Number. If you need to enter long numeric strings, but don't want them converted, then format the cells in question as Text before you input or paste your values into Excel.

Yes, but it takes a few steps. First, select the cell or cells where you want this to happen and use Ctrl+1 to bring up the Format > Cells dialog, then Alignment > Text control > check the Wrap Text option. Next, adjust your completed TEXT function to include the ASCII function CHAR(10) where you want the line break. You might need to adjust your column width depending on how the final result aligns.

Example of using TEXT with CHAR(10) to insert a line break. ="Today is: "&CHAR(10))&TEXT(TODAY(),"MM/DD/YY")

In this case, we used: ="Today is: "&CHAR(10)&TEXT(TODAY(),"mm/dd/yy")

Yes, you can use the UPPER, LOWER and PROPER functions. For example, =UPPER("hello") would return "HELLO".

Do you have a specific comment about this function?

We're updating this article! Send an email and let us know what you'd like to see.


Although we will try to read every email, we cannot guarantee a response to each and every one. Also, please do not send us any personal or sensitive information.

See Also

Create or delete a custom number format

Convert text to numbers

CONCAT function (Office 365, Excel 2016 and later)


Split text into different cells with Data > Text to Columns

Split text into different cells with functions

Add custom Headers and footers in a worksheet

Overview of formulas in Excel

How to avoid broken formulas

Use error checking to detect errors in formulas

Excel Keyboard shortcuts

Excel functions (alphabetical)

Excel functions (by category)

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!