TEXT function – Office Support

TEXT function – Office Support

TEXT function - Office Support

The TEXT function lets you switch the way a number shows up 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.

The TEXT function syntax has the following arguments:

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 Two decimals, like $1,234.57. Note that Excel rounds the value to Two 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%

Fraction, like Four 1/Three

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

Scientific notation, like 1.22E+07

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

Add leading zeros (0), like 0001234

Note: Albeit you can use the TEXT function to switch formatting, it’s not the only way. You can switch the format without a formula by pressing CTRL+1 (or +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 go after along, or create your own TEXT function format codes.

Other format codes that are available

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

Press Ctrl+1 ( +1 on the Mac) to bring up the Format Cells dialog.

Select the format you want from the Number tab.

Select the Custom-made option,

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.

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

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.

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-made option to copy those format codes to your TEXT function.

  • Select a number format
  • Leading zero’s (0’s)
  • Display a thousands separator
  • Number, currency and accounting formats
  • Dates
  • Times
  • Percentages
  • Fractions
  • Scientific notation
  • Special formats

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 come in 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 eliminated 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.

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 “#,

Related movie: Baby Play \

Leave a Reply

Your email address will not be published. Required fields are marked *