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.
Syntax
TEXT(value, format_text)
The TEXT function syntax has the following arguments:
Argument Name |
Description |
value |
A numeric value that you want to be converted into text. |
format_text |
A text string that defines the formatting that you want to be applied to the supplied value. |
Overview
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.
Formula |
Description |
=TEXT(1234.567,«$#,##0.00») |
Currency with a thousands separator and 2 decimals, like $1,234.57. Note that Excel rounds the value to 2 decimal places. |
=TEXT(TODAY(),«MM/DD/YY») |
Today’s date in MM/DD/YY format, like 03/14/12 |
=TEXT(TODAY(),«DDDD») |
Today’s day of the week, like Monday |
=TEXT(NOW(),«H:MM AM/PM») |
Current time, like 1:29 PM |
=TEXT(0.285,«0.0%») |
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. |
=TEXT(12200000,«0.00E+00») |
Scientific notation, like 1.22E+07 |
=TEXT(1234567898,«[<=9999999]###-####;(###) ###-####») |
Special (Phone number), like (123) 456-7898 |
=TEXT(1234,«0000000») |
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 +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:
-
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 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 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.
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.
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.
To find the format code for a currency symbol, first press Ctrl+1 (or +1 on the Mac), select the format you want, then choose a symbol from the Symbol drop-down:
Then click Custom on the left from the Category section, and copy the format code, including the currency 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.
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.
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.
You can alter the way decimal values display with fraction (?/?) formats.
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.
Excel provides 4 special formats:
-
Zip Code — «00000»
-
Zip Code + 4 — «00000-0000»
-
Phone Number — «[<=9999999]###-####;(###) ###-####»
-
Social Security Number — «000-00-0000»
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.
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.
Our updated formula is:
-
Cell C2:=A2&» «&TEXT(B2,»mm/dd/yy») — Date format
Frequently Asked Questions
Yes, you can use the UPPER, LOWER and PROPER functions. For example, =UPPER(«hello») would return «HELLO».
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.
In this case, we used: =»Today is: «&CHAR(10)&TEXT(TODAY(),»mm/dd/yy»)
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.
See Also
Create or delete a custom number format
Convert numbers stored as text to numbers
All Excel functions (by category)
Purpose
Convert a number to text in a number format
Return value
A number as text in the given format.
Usage notes
The TEXT function returns a number formatted as text, using the number format provided. You can use the TEXT function to embed formatted numbers inside text.
The TEXT function takes two arguments, value and format_text. Value is the number to be formatted as text and should be a numeric value. If value is already text, no formatting is applied. Format_text is a text string that contains the number formatting codes to apply to value. Supply format_text as a text string enclosed in double quotes («»). To see examples of various number format codes, see Excel Custom Number Formats.
Note: The output from TEXT is always a text string. To format a number and maintain the numeric value, apply regular number formatting.
The TEXT function is useful when concatenating a formatted number to a text string. For example, «Sales last year increased by over $43,500», where the number 43500 has been formatted with a currency symbol and thousands separator. Without the TEXT function, the number formatting will be stripped. This is especially problematic with dates, which appear as large serial numbers. With the TEXT function, you can embed a number in text using exactly the number format needed.
Examples
With the date July 1, 2021 in cell A1, the TEXT function can be used like this:
=TEXT(A1,"dd-mmm-yy") // returns"1-Jul-2021"
=TEXT(A1,"mmmm d") // returns "July 1"
With the number 0.537 in cell A1, TEXT can be used to apply percentage formatting like this:
=TEXT(A1,"0.0%") // returns "53.7%"
=TEXT(A1,"0%") // returns "54%"
The TEXT function is especially useful when concatenating a number to a text string with formatting. For example, with the date July 1, 2021 in cell A1, concatenation causes date formatting to be removed, since dates are numeric values:
="The date is "&A1 // returns "The date is 44378"
The TEXT function can be used to apply date formatting in the final result:
="The date is "&TEXT(A1,"mmmm d") // returns "The date is July 1"
Notes
- Value should be a numeric value
- Format_text must appear in double quotation marks.
- The TEXT function can be used with custom number formats
What is the Text Function in Excel?
The TEXT function in Excel converts numbers from the numerical format to text format by using formatting codes. We can use it to display numbers as words, including symbols, while maintaining the numeric value. The TEXT function also helps concatenate numbers to formatted text strings or symbols.
Example, =TEXT(A6,”dd mmmm, yyyy”) converts the numerical Date 27-01-2023 into the text format 27 January, 2023
Key Highlights
- We use the TEXT function in Excel to convert Dates into a specific format.
- It does not support a fractional format.
- We use the TEXT function to combine numbers with characters or text.
- We cannot combine the time, Date, #, and 0 in the TEXT function formula.
- Excel gives an error #Name if there are no quotation marks around the argument ‘format_text’.
The Syntax for TEXT Function in Excel
The syntax for the TEXT function is
- Value (required): It indicates the numeric value we want to convert to text. The value can be a number, Date, reference to a cell containing a numeric value, or any other function that returns a number or Date.
- format_text (required): It is a format you want to apply. We must provide the argument as format code enclosed in quotation marks, g., “mm/dd/yy”.
How to Use the TEXT Function in Excel?
Consider the following examples to understand the use of the TEXT function:
You can download this TEXT Function Excel Template here – TEXT Function Excel Template
Example #1
Consider the below table, which shows a Date in “dd-mm-yyyy” format. We want to convert it into – “mmmm d, yyyy” using the TEXT function.
Solution:
Step 1: Place the cursor in cell C6 and enter the formula,
=TEXT(B6,”mmmm d,yyyy”)
Explanation:
- B6: It is the cell containing an unformatted parameter (Date)
- “mmmm d,yyyy”: The open and closed double quotes indicate the output in text format.
- mmmm: Four times m indicates the month in complete spelling, i.e., January; To write month as only Jan, we need to put it three times, i.e., mmm (refer to the below image)
- d: A single d indicates Dates in single digits, i.e., 2
- yyyy: Four times y indicate the year in four digits, i.e., 2019
Step 2: Press Enter key to get the below result
Example #2
The table below shows the time and Dates in columns B and C, respectively. We want the values of the time and Date columns to appear together in column C.
Solution:
Step 1: Place the cursor in cell D6
Note: If we use the CONCATENATE function to combine the values of columns B and C, it gives time in an incorrect format, as seen in the image below. Therefore, we need to use the TEXT function to provide the values in a proper form.
Step 2: Enter the TEXT formula,
=TEXT(B6,”h:mm:ss AM/PM”)& ” “&TEXT(C6,”m/d/yyyy”)
Explanation:
- h:mm:ss AM/PM: It indicates the desired time format
- &” “&: It acts as a separator between the two text
- m/d/yyyy: It indicates the desired Date format
Step 3: Press Enter key to get the below result
The result is combined time and Date values in single cell D6.
Step 4: Drag the formula in other cells to get the below result
Example #3
The below table shows the scientific notation of a list of mobile numbers with their country codes. We want to use the TEXT function to convert the mobile numbers into the correct and readable format.
Important: In a Microsoft Excel worksheet, when we enter a value with the number of digits greater than 11, Excel converts that value into a scientific notation in a non-readable format. We can use the TEXT function to convert it into a readable format.
Follow these steps to understand this-
Step 1: Place the cursor in cell D6 and enter the formula,
=TEXT(C6,”############”)
Explanation:
- C6: It is the cell containing the mobile number
- ############: The 12-digit # codes convert numbers in scientific notation into readable format.
Step 2: Press Enter key to get the below result
Step 3: Drag the formula in other cells to get the below result
Tip: We can differentiate the country code from the mobile number by inserting a hyphen (-) at the desired location in the Text Formula
So,
Step 4: Modify the formula by inserting a hyphen (-) after two digits in the formula, as shown below,
Step 5: Drag the formula in other cells to get the below result
Using Concatenate and Text Function in Excel Together
We want to display the present day and Date using the TEXT function.
Solution:
Place the cursor in cell B5 and enter the formula,
=CONCATENATE(“Today is”,” “, TEXT(TODAY(),”dddd d mmm, yyy”))
Explanation:
- TODAY(): Indicates the present day of the week
- dddd d mmm, yyy: Indicates the current Date with the day.
The formula combines (concatenates) the text Today is with the present day to give the result- Today is Wednesday 25 Jan, 2023.
How to Get the Format Codes for Text Function in Excel?
To locate the format codes for time:
Right-click the desired cell > Go To Format Cells > Number > Custom > Select the desired time Type from list > OK.
To locate the format codes for the Date:
Right-click the desired cell > Go To Format Cells > Number > Custom > Select the desired Date Type from the list > OK.
Shortcut: To open Format Cells,
- Press CTRL+1 in windows, and
- +1 in Mac
List of Format Codes for TEXT Function in Excel
The Text function accepts most format codes used in Excel number formats. Below is a table with the most common and frequently used format codes.
*In addition, we can include any of the below characters in the format code, and they will be displayed as entered.
Format Codes used in Excel while dealing with Dates
List of Built-in Excel Text Functions
Below is a list of built-in Text functions in Excel with their uses
Things to Remember
- The Text function in Excel cannot convert numbers from 123 formats to One Two Three. To do so, we have to use Visual Basics (VBA).
- The Text function converts a numeric value to a formatted text; therefore, we cannot use the result for calculation purposes.
- The ‘format_text’ argument in the text function formula cannot contain an asterisk character (*).
- TEXT function is available in the following versions of Microsoft Excel- Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, and Excel 2000.
Frequently Asked Questions (FAQs)
Q1) What are the arguments of text function?
Answer: The TEXT function takes two arguments- value and format_text.
Value: It is the number we need to format as text. The function will not apply a format code if the argument is already text.
format_text: It is a text string (format) that we want to apply to the value. We must provide the argument in quotation marks to give the correct result.
Q2) How do you use the text function in sheets?
Answer: To use the TEXT function in Google sheets, consider the below example
- Place the cursor in the cell where you want the result
- Type the formula,
=TEXT(A4,”HH mm”)
The formula will convert the time format from 12 Hrs format (4:15:00 PM) to 24 Hrs Format (16 15)
Q3) What is the use of text functions in Excel?
Answer: The TEXT function lets you convert numbers into a more readable format. We can change the appearance of numbers to the desired forms by applying the format codes in Excel.
Q4) How to use text function in excel?
Answer: To understand using the TEXT function, consider the below example,
- Place the cursor in cell B6
- Type the formula,
=TEXT(A6,”0%”)
The formula will convert the decimal 0.565 to the percentage format as 57%.
Recommended Articles
The above article is a guide to using Text Function in Excel. To learn about more Excel-related concepts, EDUCBA recommends the below-given articles.
- Excel Text with Formula
- Formatting Text in Excel
- Search For Text in Excel
- VBA Text
The TEXT function in Excel converts numeric values to a text string. While you’ll mostly be fiddling with numbers on an Excel sheet, you may often need to convert a few values into text. The TEXT function is available in all versions of Excel starting from Excel 2003.
Syntax
The syntax of the TEXT function is as follows:
=TEXT(value, format_text)
Arguments:
‘value’ – This is a required argument where you input the numeric value you want to convert to a text string. The supplied value can be a number, date, or a cell reference that contains a number, date, or an output from another formula that’s a number or date.
‘format_text’ – This is a required argument where you prescribe a format for the output using a format code. You can use any formatting code that Excel recognizes.
Format Codes for TEXT function
Here is a list of the most commonly used format codes that can be used with the TEXT function:
Code | Description | Example |
---|---|---|
# | Placeholder that displays significant digits. | #.## – displays up to 2 decimal places. This means if the value fed to the function is 1.755 the result will be 1.76 |
0 | Placeholder that displays insignificant zeros. | #.000 – always displays 3 decimal places. This means if the value fed to the function is 1.75 the result will be 1.750 |
? | Placeholder that leaves a space for insignificant zeros but doesn’t display them. Used for presenting aligned decimals. | #.??? – displays a maximum of 3 decimal places and aligns the decimal points in the column. |
. | Decimal point | – |
, | Thousands separator | ###,###.## – displays a thousands separator with 2 decimal places. This means if the value fed to the function is 175000, it will display as 175,000.00 |
d | Day of Week or Month | d – one or two-digit number representing the day of the month without a leading zero ranging from 1 to 31
dd – two-digit number representing the day of the month with a leading zero ranging from 01 to 31 ddd – three-letter abbreviation for the day of the week (Mon to Sun) dddd – full name of the day of the week (Monday to Sunday) |
m | Month of the Year | m – one or two-digit number representing the month of the year without a leading zero ranging from 1 to 12
mm – two-digit number representing the month of the year with a leading zero ranging from 01 to 12 mmm – three-letter abbreviation for the month of the year (Jan to Dec) mmmm – full name of the month of the year (January to December) |
y | Year | yy – two-digit number representing the last two digits of the year (e.g. 08 meaning 2008 or 20 meaning 2020)
yyyy – four-digit number representing the year (e.g. 2008, 2020) |
h | Hour | h – one or two-digit number representing the hour component without a leading zero (1 to 24)
hh – two-digit number representing the hour component with a leading zero (01 to 24) |
m | Minute (when used as part of time) | m – one or two-digit number representing the minute component without a leading zero (1 to 60)
mm – two-digit number representing the minute component with a leading zero (01 to 60) |
s | Second | s – one or two-digit number representing the second component without a leading zero (1 to 60)
ss – two-digit number representing the second component with a leading zero (01 to 60) |
AM/PM | Represents the time in 12-hour clock format, followed by «AM» or «PM» | – |
Apart from the above codes if you want to display specific characters in your output, you can enter them right into the format code and they will be displayed exactly the way they have been entered. Following are the characters you can input:
Character | Description |
---|---|
+ | Plus |
– | Minus |
() | Left/right parenthesis |
{} | Curly brackets |
<> | Less than/greater than |
: | Colon |
^ | Caret |
‘ | Apostrophe |
~ | Tilde |
/ | Forward slash |
! | Exclamation mark |
& | Ampersand |
= | Equal to |
Space |
Important Characteristics of the TEXT function
- The TEXT function doesn’t convert numbers to words, just text strings. For instance, if you convert 10,000 using the TEXT function, Excel will then recognize it as a text string and not a numeric value, but the function can’t convert it to the words «Ten Thousand.»
- You’ll need to specify a format for the converted text.
- If you enter the format code incorrectly, you’ll receive a #NAME? error.
- Once you convert a numeric value using the TEXT function, you can’t manipulate it in your workbook calculations.
Examples
Let’s try to see some examples of the TEXT function.
Example 1 – Plain Vanilla Formula for the TEXT Function
Let’s use the formula on a simple, Excel-recognized date just to look at how the TEXT function works. We’ll supply a date to the function and try to format it as a «dd.mm.yyyy» text string. Here’s the formula that will help you accomplish this:
=TEXT("12/25/2000","dd.mm.yyy")
Notice how even though the original date is in the mm/dd/yyyy format, you can use the TEXT function to not only convert this date into a text string but also display it in the dd.mm.yyyy format. If you’re aiming for a more sophisticated output, you do have the option to make your date look more textual and less numeric. You’d just need to use a different format code, like so:
=TEXT("12/25/2000","mmmm d, yyyy")
This gives you a neater output. You can, of course, obtain a lot of different outputs you offer by using the relevant format code.
Alright, that takes care of the bare-bones formula, let’s do some other cool things using the TEXT function
Example 2 – Basic Arithmetic and Concatenation with the TEXT Function
Before we get to the actual example, let’s take a moment to see what you’re going to learn here.
TEXT function allows us to perform basic arithmetic operations with the values that are supplied to it. Instead of directly supplying a value or cell reference, you can do some arithmetic within the argument.
And in addition to this, it also supports concatenation. Concatenation relates to combining the output of the TEXT function with another text string to make the output more contextual.
Okay, so consider that you’re at your job or business desk looking at a price list. You plan on offering discounts to customers, and each product has a different discount rate. You have a list of customers that have gotten in touch with you to claim their discount, and you need to compute their final price. You plan on using the mail merge feature in MS Word and send the customers a letter about their final price.
You’ve got the original price and the discount rate for Product A listed on your sheet. In the third column labeled MESSAGE, you want the final message that you’ll send to your customers. Here’s the formula you can use to do this:
="The discounted price is "&TEXT(A2*(1-B2),"$###,###.00")
There are a couple of things going on in this formula. The first portion of the formula is just a plain text string; no formulas in the first portion. The text string is concatenated using the ampersand (&), which means the text string will be connected with the text string that the second portion of the formula returns.
Let’s switch over to the second part of the formula, where we’ve used the TEXT function. The first argument, this time, is an arithmetic operation instead of a numeric value supplied directly or as a cell reference. The calculation is essentially for the discounted price. The second portion of the formula is again just a format code, which will format the output in a way that it has a comma separator after every three digits, and with two decimal values at the end.
The final output gives you a ready to import text string that you can use in your mail merge letters or envelopes for marketing. Who knew Excel could contribute to your marketing efforts, eh?
Alright, let’s flex our muscles a little more.
Example 3 – Add Padding Zeros to Numbers with the TEXT Function
This is one of the most common use-cases of the TEXT function. When you have a list of numbers with a varying number of digits, and you want a nice list where all numbers that have less than a certain number of digits have 0s at the beginning. Let’s make this a little clearer with an example.
Say you’ve got some numbers piled up in your worksheet. The smallest number is 2 digits, while the largest number is 7 digits. You want to give it a tidy look so all numbers will essentially be 7 digits. Here’s the formula you could use:
=TEXT(A2,"0000000")
You’re effectively just giving the cells a format where any number with less than 7 digits will have 0s as a prefix for padding. Note that once you’ve applied the TEXT function to these numbers, they’re no longer numbers that you can manipulate on your spreadsheet, they’re just text strings.
You can now feed your secret OCD just right.
Example 4 – Get Day Name from Week
You’ve been told that some employees have been slacking off and you intend to set things straight with them. You have a software that records attendance from employees, but unfortunately, the software also includes the weekends into the list of days when employees wouldn’t have punched their cards in.
You now have a list of dates on which your employees didn’t show up, but you need to weed out the holidays from working days. Manually, this could take you about a million years. Thanks to Excel, we’ve got a way to accomplish this within a couple of seconds.
Assume that you give Saturdays and Sundays off. Then, you’ll need to identify the dates that fall on a Saturday or Sunday so you don’t end up nagging the employee for no good reason. Once you’ve got the Saturdays and Sundays out of the list, you know which workdays your employees didn’t show up on.
Perhaps, you could call upon the TEXT function for some help with the following formula:
=TEXT(A2,"dddd")
Since the format has been set to «dddd» it shows the full name of the day. You could also choose to format the output as «ddd» to display the output as Mon, Tue, Wed, etc.
As you’d have noticed, all we’re doing with this formula is just changing the dates into text and formatting it such that the final output displays the day component of the date. If you have a fairly large list, you can also give your output some conditional formatting so you can eyeball employees that have taken excessive holidays.
There’s one more thing you can use the same formula for, but you’ll need to tweak it just a tad. Let’s talk about that in the next example.
Recommended Reading: Get Day of Week From Date In Excel
Example 5 – Get Month Name from Week
Say you’re now keen on analyzing which month witnessed the highest leaves. Maybe, the absenteeism was a cause of flu season. To understand this, you need to see which month the dates where employees didn’t show up fall in.
To accomplish this, you can use a slight variation of the previous formula. If you hadn’t guessed it already, the formula is:
=TEXT(A2,"mmmm")
This is the same formula we used in the previous example, but this time, the final output has been formatted to show the name of the month instead of the day. Note that all output cells are now formatted as text strings and you cannot use them for manipulation on your worksheet.
Like we discussed in the previous example, you can also give the output in this example different formatting if you so choose. For instance, if you want to display the three-word abbreviation of a month (like Jan, Feb, Mar, etc.) instead of the full name, you could use the «mmm» format.
All set? Alright, time to play with some numbers.
Example 6 – Convert Numbers to Phone Number Format
Have you had to skim through what looks like a gazillion phone numbers, all of which have a country code as a prefix? It makes you dizzy looking through the digit-dense list, but a little formatting could make things a lot easier for you.
Say you’ve got some cell phone numbers listed on your spreadsheet. They’re all 10-digit numbers but have a country code in front of them. You want to separate the country code so it’s easier to see which country the number belongs to.
Remember, the TEXT function gives you a ton of ammunition for custom formatting the output. Therefore, it can be a great tool to tidy up your spreadsheet regardless of what data you have in your cells. Here’s the formula we’ll use to clean up the list of phone numbers:
=TEXT(A2,"(##) ##### #####")
You now have all country codes in brackets, well organized, and easy to read.
Also, remember those characters we said you could add to the format and they’ll appear as they are entered in the formula? We’ve used parentheses in this formula and notice how they appear as-is in the final output. If you prefer, you could even add dashes instead of spaces between the numbers, and it would work just fine.
Pretty cool, huh?
Example 7 – Concatenate a Date with Text Using the TEXT Function
Say you want to create an output where there’s a text string concatenated with the DATE function to display something like, «Today is January 1, 2001». Go ahead and give it a try. If you don’t know the formula, here you go:
= "Today is " &DATE(2001,1,1)
See the problem?
This formula gives you an output where the DATE is displayed as a serial number. Technically, Excel is doing everything that it’s supposed to. For Excel, a date is a serial number and is displayed as such unless otherwise formatted.
As we discussed previously, the TEXT function carries plenty of power when it comes to formatting the output. So, we’ll add the TEXT function to the mix just to change the format of the output.
Note that the Excel function is doing nothing except for formatting in the following formula:
="Today is "&TEXT(DATE(2000,12,25),"mmmm d, yyyy")
Notice that all that’s different in this formula is that we’ve nested the DATE function inside the TEXT function so we can format the serial number as «mmmm d, yyyy». The DATE function relays the serial number to the TEXT function, which then converts it into the prescribed format.
Easy-peasy, isn’t it?
Alright, that’s a wrap for the TEXT function. TEXT function, quite literally, is one of the most versatile functions when it comes to formatting. It can help you organize and tidy up almost any data set you have based on your preferred output format. So, once you’ve championed all these formulas (they’re quite easy, aren’t they?), we’ll have the next tutorial ready for you to get your hands dirty with. Meanwhile, stay curious!
The TEXT excel function converts a number to a text string based on the format specified by the user. This format is supplied as an argument to the TEXT function. Since the resulting outputs are text representations of numbers, they cannot be used as is in formulas. Therefore, it is recommended to retain the original numbers and create a separate row or column for the converted numbers.
For example, the formula “=TEXT(“10/2/2022″,”mmmm dd, yyyy”)” returns February 10, 2022. Exclude the beginning and ending double quotation marks while entering this formula in Excel.
The purpose of using the TEXT function in Excel is to display a number in the desired format. Since this function also helps combine numbers with other text strings, it tends to make the output more legible. The TEXT function is particularly used when the number formats of different datasets need to be made identical.
Estimated reading time: 21 minutes
Table of contents
- What is Text Function in Excel?
- Syntax of the TEXT Function of Excel
- How to Use the TEXT Function in Excel?
- Example #1–Prefix the Text Strings to the Newly Formatted Date Values
- Example #2–Join the Newly Formatted Time and Date Values
- Example #3–Extract a Mobile Number from its Scientific Notation
- Example #4–Prefix a Text String to the Initially Formatted Monetary Value
- Date Formats of Excel
- Frequently Asked Questions
- TEXT Function in Excel Video
- Recommended Articles
Syntax of the TEXT Function of Excel
The syntax of the TEXT function of Excel is shown in the following image:
The TEXT function of Excel accepts the following arguments:
- Value: This is the number to be converted to a text string. Apart from a number, a date, time or cell reference can also be supplied to the TEXT excel function. The cell reference can contain either a number or an output of another function which can be a number or date.
- Format_text: This is the format to be applied to the “value” argument. It is also called the format code. It is entered within double quotation marks in the TEXT formula of Excel. For instance, “0.00,” “dd/mm/yyyy,” “hh:mm:ss,” and so on are format codes.
Both the stated arguments are mandatory.
Note 1: The format code “0.00” displays a number with two decimal places. In the format code “dd/mm/yyyy,” “dd,” “mm,” and “yyyy” are the notations for days (in two digits), months (in two digits), and years (in four digits) respectively.
Likewise, “hh,” “mm,” and “ss” are the notations for hours (in two digits), minutes (in two digits), and seconds (in two digits) respectively.
For the meaning of the different date formats, refer to the heading “date formats of Excel” given after example #4 of this article.
Note 2: The TEXT function is categorized as a Text/String function of Excel. The TEXT function is available in all versions of Excel.
How to Use the TEXT Function in Excel?
Let us consider some examples to understand the working of the TEXT function in Excel.
Example #1–Prefix the Text Strings to the Newly Formatted Date Values
The following table shows the names of five children along with the dates they were born on. The dates are currently in the format m/d/yyyy. Consider the two columns and six rows of the table as columns A and B and rows 1 to 6 of Excel.
We want to perform the following tasks:
- Join the name and date of birth of row 2 by using the ampersand operator. There should not be any space between the joined values.
- Convert each date to the format “dd mmm, yyyy.” Prefix the child’s name and the string “was born on” to each date.
- Show the output when the date of row 2 is in the format “d mmm, yyyy.” Let the prefixes of the preceding point stay as it is.
- Show the date formats “dd mmm, yyyy” (in cell C2) and “d mmm, yyyy” (in cell C6) in a single column.
Explain the outputs obtained in the second and fourth bullet points. Use the TEXT function of Excel.
Name of Kid | Date of Birth |
---|---|
John | 12/8/2015 |
Patricia | 1/12/2014 |
Ram | 3/11/2016 |
Anita | 11/11/2017 |
Davis | 5/6/2014 |
The steps to perform the given tasks by using the TEXT function of Excel are listed as follows:
Step 1: Enter the following formula in cell C2. Exclude the beginning and ending double quotation marks while entering the given formula.
“=A2&“”&B2”
This formula (shown in the image of step 2) joins the values of cells A2 and B2 without any spaces in-between.
Note: The ampersand operator (&) helps join the values of two or more cells. It is called the concatenation operator and is used as an alternative to the CONCATENATE function of Excel. There is no limit on the number of cell values that the ampersand can join.
Step 2: Press the “Enter” key. The output appears in cell C2, as shown in the following image.
Notice that Excel has joined the values of cells A2 and B2 without any spaces in-between. However, the output is not in a readable format. The reason is that the date (12/8/2015) has been converted to a sequential number. The number 42346 represents the date December 8, 2015.
Note: A date is stored in Excel as a sequential or a serial number. This is because a serial number makes it easy to perform calculations. To view the serial number of a date, refer to the “note” preceding step 3 of example #2.
Step 3: To apply the format “dd mmm, yyyy” and insert the stated prefixes, enter the following formula in cell C2.
“=A2&” was born on “&TEXT(B2,”dd mmm, yyyy”)”
Press the “Enter” key. Then, drag the formula of cell C2 till cell C6 by using the fill handle. The outputs are displayed in the following image.
Explanation of the outputs: In column C of the preceding image, the child’s name (in column A) and the text string (was born on) have been prefixed to each date of column B. Since the date is in a suitable format, the output is readable now.
The joined values (outputs) of column C are in the form of statements that are easier to understand than the single values of columns A and B.
Notice that, to insert spaces as the separators in the output, we have inserted spaces at the relevant places in the formula of step 1. Moreover, a comma has also been inserted after the notation of months (mmm). This comma can be seen in each date of the output (in column C).
Step 4: To see the output when the date format is “d mmm, yyyy” and the prefixes are in place, enter the following formula in cell C2.
=A2&” was born on “&TEXT(B2,”d mmm, yyyy”)
Press the “Enter” key. The output appears in cell C2, as shown in the following image.
Notice that the leading zero before the date 8 Dec, 2015 (in cell C2) has disappeared. This zero was there in cell C2 of the preceding image. It has disappeared because, in the current format code, the number of days is represented by a single “d.”
A single “d” omits the leading zeros when the number of days is in a single digit.
Step 5: The outputs obtained after applying different date formats in the same column (column C) are shown in the following image.
Explanation of the outputs: Notice that in the preceding image, the date of cell C2 is in the format “d mmm, yyyy” while that of cell C6 is in the format “dd mmm, yyyy.” The only difference between these two date formats is in the number of days. The leading zero is absent in cell C2 and present in cell C6.
Hence, with the TEXT function of Excel, one can have different date formats in different cells of the same column. Remember that a format code changes only the appearance of a value; it does not change the value itself. One can create a format code depending on the requirement.
Example #2–Join the Newly Formatted Time and Date Values
The following table shows the times and dates in two separate columns. Consider these columns as columns A and B of Excel. We want to perform the following tasks:
- Join (concatenate) each time value with the respective date. Use the ampersand operator (&) and ensure that there is no space between the two values.
- Show how to copy the formats “h:mm:ss am/pm” and “m/d/yyyy” from the “format cells” window. Convert each time to the former and date to the latter format.
- Join the converted time and date values with the ampersand operator (&). Ensure that there is a space between the two values.
- Show the output when the date format is not enclosed within double quotation marks.
Explain the outputs obtained in the first and third bullet points. Use the TEXT function of Excel for the given tasks.
Time | Date |
---|---|
7:00:00 AM | 6/19/2018 |
7:15:00 AM | 6/19/2018 |
7:30:00 AM | 6/19/2018 |
7:45:00 AM | 6/19/2018 |
8:00:00 AM | 6/19/2018 |
8:15:00 AM | 6/19/2018 |
8:30:00 AM | 6/19/2018 |
8:45:00 AM | 6/19/2018 |
The steps to perform the given tasks by using the TEXT function of Excel are listed as follows:
Step 1: Enter the following formula (without the beginning and ending double quotation marks) in cell C2.
“=A2&“”&B2”
This formula is shown in the image of step 2. It joins the values of cells A2 and B2 without a space in-between.
Step 2: Press the “Enter” key. Then, drag the formula of cell C2 till cell C9 by using the fill handle. The fill handle is displayed at the bottom-right side of cell C2.
The outputs are shown in the following image.
Explanation of the outputs: In column C, the number 43270 (at the end) is the same throughout the range C2:C9. This is the serial number for the date June 19, 2018. The entire decimal number preceding this serial number is the time. So, the decimal number 0.2916667 (in cell C2) represents the time 7:00:00 am.
The outputs obtained in column C of the preceding image are not readable. The reason is that Excel has converted the times (of column A) to decimal numbers and dates (of column B) to sequential numbers. Moreover, joining the decimals with sequential numbers has made the outputs more complicated.
To be able to read the output, it needs to be converted to the relevant format codes. This conversion is shown further in this example.
Note: Excel stores dates as sequential (or serial) numbers and times as decimal numbers. Excel considers a time value as a part of a day. To view the number representing the date, perform the following actions:
- Select any cell of the range B2:B9.
- Press the keys “Ctrl+1” together. The “format cellsFormatting cells is an important technique to master because it makes any data presentable, crisp, and in the user’s preferred format. The formatting of the cell depends upon the nature of the data present.read more” window opens.
- Select “general” under “category” in the “number” tab.
The serial number can be seen under “sample.” Click “cancel” to close the “format cells” window or “Ok” to change the date to a serial number.
Likewise, the decimal number representing the time can also be seen by selecting any cell of the range A2:A9 and following actions “b” and “c” listed above.
Step 3: To convert the time and date values to a readable format, let us first copy the format codes from the “format cells” window. So, select cell C2 and press the keys “Ctrl+1” together.
The “format cells” window opens, as shown in the following image. From the “number” tab, select “custom” under “category. Excel provides a list of formats under “type.”
Step 4: Scroll down the list of formats given under “type.” Copy the format “h:mm:ss am/pm.” To copy, just select the format code and press the keys “Ctrl+C.”
The format code is shown in the following image. Once the format has been copied, close the “format cells” window.
Step 5: Copy the format code “m/d/yyyy” for converting the date values. This format code is also available under “type,” as shown in the following image.
Close the “format cells” window after copying the mentioned format code.
Step 6: To apply the new formats to the time and date values and join the resulting values, enter the following formula in cell C2.
“=TEXT(A2,”h:MM:SS AM/PM”)&” “&TEXT(B2,”m/d/yyyy”)”
This formula is shown in the image of step 7. If the format codes have been copied in the preceding steps, they can be pasted at the relevant places in the formula by pressing the shortcut “Ctrl+V.”
According to this formula, the time and date values of cells A2 and B2 are formatted as per the codes “h:MM:SS AM/PM” and “m/d/yyyy” respectively. The formatted (or converted) values are then joined with the ampersand operator.
Notice that in the formula, a space has also been entered within a pair of double quotation marks (like &“ ”&). This space will be inserted in the output at exactly that place where it has been entered in the formula.
Step 7: Press the “Enter” key after entering the TEXT formula. Drag the formula of cell C2 till cell C9.
The outputs are shown in the following image.
Explanation of the outputs: The time and date values of columns A and B have been converted to the relevant formats in column C. The time values display the hours (h) in a single digit, minutes (mm) in two digits, and seconds (ss) also in two digits. Since all the time values belong to the period before noon, they display “am” at the end.
Likewise, the dates display the months (m) in a single digit, days (d) in a single digit, and years (yyyy) in four digits.
Notice that there is a space between the two joined values in column C. Even though we copied the code “h:mm:ss am/pm” (in step 4) and pasted “h:MM:SS AM/PM” (in step 6), we obtained the correct outputs in column C (in step 7). This is because the format codes are not case-sensitive, implying that “mm” is treated the same as “MM.”
Step 8: To see what happens when the format code for date is entered without the double quotation marks, type the following formula in cell C9.
“=TEXT(A2,”h:MM:SS AM/PM”)&” “&TEXT(B2,m/d/YYYY)”
Press the “Enter” key. Excel returns the “#NAME?” error, as shown in the following image. Therefore, for the TEXT excel function to work, the format code should necessarily be enclosed within double quotation marks.
There are two images titled “image 1” and “image 2.” The following information is given:
- Image 1 shows a number having eleven 9s in cell B2. When 1 is added to this number, its digits increase to 12. Excel displays the resulting 12-digit number (in cell B3) in a scientific notation.
- Image 2 shows the names of some people (in column A) and their random mobile numbers in a scientific notation (in column B). The formula bar shows the mobile number of person A. Each mobile number consists of twelve digits, which includes a 2-digit country code at the beginning.
Note that a scientific notationIn Excel, scientific notation is a specific style of writing numbers in scientific and exponential forms. Scientific notation compactly helps display values, allowing us to compare and use the same in calculations.read more (or scientific format) often displays very large or very small numbers in a contracted form. We want to perform the following tasks:
- Display the entire 12-digit mobile number without any spaces in-between.
- Separate the country code from the rest of the number with the help of a hyphen.
Use the TEXT function of Excel for the given tasks.
Image 1
Image 2
The steps to perform the given tasks by using the TEXT function of Excel are listed as follows:
Step 1: Enter the following formula in cell D2.
“=TEXT(B2,”############”)”
This formula is shown in the formula bar of the succeeding image. Notice that there are 12 hashes in the formula, which represent the 12 digits of a mobile number.
Step 2: Press the “Enter” key. The output appears in cell D2. To obtain the outputs for the entire column D, drag the formula of cell D2 to cell D7. Use the fill handle of cell D2 (displayed at the bottom-right corner) for dragging.
The outputs of column D are shown in the succeeding image.
Note: The output is displayed (in column D) only when one enters a mobile number as an input (in column B) which is converted automatically (or manually) to a scientific format of Excel. In case, a scientific format is typed manually in column B; it cannot be converted to a mobile number of column D.
Step 3: To separate the country codes from the rest of the number by using a hyphen, enter the following formula in cell D2.
“=TEXT(B2,“##-##########”)”
Press the “Enter” key. Next, drag the formula of cell D2 till cell D7 with the help of the fill handle. The formula of cell D2 and the outputs are shown in the following image.
Notice that in the formula, the hyphen is placed exactly where it is required in the output. Since only the first two digits of each mobile number are to be separated, the hyphen is placed after two hashes of the formula.
Example #4–Prefix a Text String to the Initially Formatted Monetary Value
There are two images titled “image 1” and “image 2.” The following information is given:
- Image 1 shows the gross profit, expenses, and net profit of an organization. All these numbers are in dollars.
- Image 2 shows how the net profit has been computed. To calculate the net profit, the expenses have been subtracted from the gross profit.
We want to perform the following tasks:
- Show the output when the string “the net profit is” is prefixed to the amount of net profit. Use the ampersand operator for this purpose.
- Prefix the string “the net profit is” to the amount of net profit by using the ampersand. Ensure that in the output, the amount of net profit displays the dollar sign ($) and the comma at the correct places (like $52,291). Use the TEXT function of Excel for this purpose.
Explain the output obtained at the end.
Image 1
Image 2
The steps to perform the given tasks are listed as follows:
Step 1: Enter the following formula in cell A13.
“=”The net profit is “&B11”
Exclude the beginning and ending double quotation marks of the formula while entering it in Excel. This formula is shown in the image of step 2.
The given formula prefixes the string “the net profit is” to the value of cell B11. The ampersand helps join the stated string to the amount of net profit (in cell B11).
Step 2: Press the “Enter” key. The output appears in cell A13, as shown in the following image.
Notice that the dollar sign and the comma of the net profit amount (shown in cell B11) have been omitted in the output. Though the string “the net profit is” has been correctly prefixed. The spaces have also been inserted at the right places in cell A13.
Step 3: To retain the dollar sign and the comma of the amount, enter the following formula in cell A13.
“=”The net profit is ” &TEXT(B11,”$#,##0.00″)”
Press the “Enter” key. The formula and the output are shown in cell A13 of the following image.
Notice that by mistake, a space has been inserted before the ampersand in the formula. However, even then, the correct output has been obtained in cell A13.
Explanation of the output: This time, the amount of net profit has been properly written (including the dollar sign and the comma) in cell A13. The reason is that the amount of net profit has been converted to the appropriate format in addition to being prefixed by a text string.
So, with the TEXT function of Excel, one can join a number with any string and, at the same time, retain the initial formatting of the number.
Date Formats of Excel
The different format codes for dates have been described as follows:
Frequently Asked Questions
1. Define the TEXT function in Excel with the help of an example.
The TEXT function in Excel helps convert a numerical value to a text string. The conversion is carried out according to the format specified by the user. Once converted, the numerical value becomes a text representation of a number.
The formula “=TEXT(“2/12/2021”,“dddd-mmmm-yyyy”)” converts the date 2/12/2021 to Thursday-December-2021. Ensure that the beginning and ending double quotation marks are excluded while entering this TEXT formula in Excel.
Note: For the working of the TEXT function of Excel, refer to the examples of this article.
2. Why is the TEXT function used in Excel?
The TEXT function is used in Excel for the following reasons:
• It helps convert a numerical value to a text string having a new format.
• It eases joining a numerical value with a text string.
• It helps retain the format of the existing numerical value after concatenation (joining).
• It makes the date or time values given in sequential or decimal numbers more readable and understandable for the users.
• It helps add the leading zeros to a number.
• It allows inserting specific characters (like +,-,(),<>,: etc.) in the output.
Note: The different characters that can be entered in the TEXT formula are the plus (+), minus (-), equal to (=), parentheses (), less than and greater than signs <>, colon (:), apostrophe (‘), curly braces {}, caret (^), forward slash (/), ampersand (&), space ( ), tilde (~), and an exclamation point (!).
The characters should be entered in the format code. These characters are displayed at exactly those places (in the output) where they have been entered in the format code.
3. How is the TEXT function used to add the leading zeros to a number in Excel?
The steps to add the leading zeros to a number are listed as follows:
a. Type “=TEXT” followed by the opening parenthesis.
b. Enter the number as the “value” argument.
c. Enter those many zeros in the format code as the number of digits required in the output.
d. Close the parenthesis and press the “Enter” key.
The leading zeros are added to the number entered in step “b.”
For instance, if the number 148 should appear as a 5-digit number, enter the formula “=TEXT(“148”,“00000”)” without the beginning and ending double quotation marks. It returns 00148.
TEXT Function in Excel Video
Recommended Articles
This has been a guide to the TEXT function of Excel. Here we discuss how to use the TEXT function in Excel along with step-by-step examples. You may also look at these useful functions of Excel–
- Separate Text in ExcelThe methods used to separate text in Excel are as follows: 1) Text to Column (Delimited and Fixed Width) 2) Using Excel Formulasread more
- Add Formula Text in ExcelText in Excel Formula allows us to add text values to using the CONCATENATE function or the ampersand (&) symbol.read more
- INDIRECT in MS Excel
- Trim FunctionThe Trim function in Excel does exactly what its name implies: it trims some part of any string. The function of this formula is to remove any space in a given string. It does not remove a single space between two words, but it does remove any other unwanted spaces.read more
Convert numbers into text in a spreadsheet
What is the Excel TEXT Function?
The Excel TEXT Function[1] is used to convert numbers to text within a spreadsheet. Essentially, the function will convert a numeric value into a text string. TEXT is available in all versions of Excel.
Formula
=Text(Value, format_text)
Where:
Value is the numerical value that we need to convert to text
Format_text is the format we want to apply
When is the Excel TEXT Function required?
We use the TEXT function in the following circumstances:
- When we want to display dates in a specified format
- When we wish to display numbers in a specified format or in a more legible way
- When we wish to combine numbers with text or characters
Examples
1. Basic example – Excel Text Function
With the following data, I need to convert the data to “d mmmm, yyyy” format. When we insert the text function, the result would look as follows:
2. Using Excel TEXT with other functions
We use the old price and the discount given in cells A5 and B5. The quantity is given in C5. We wish to show some text along with the calculations. We wish to display the information as follows:
The final price is $xxx
Where xxx would be the price in $ terms.
For this, we can use the formula:
=”The final price is “&TEXT(A5*B5*C5, “$###,###.00”)
The other way to do it by using the CONCATENATE function as shown below:
3. Combining the text given with data using TEXT function
When I use the date formula, I would get the result below:
Now, if we try to combine today’s date using CONCATENATE, Excel would give a weird result as shown below:
What happened here was that dates that are stored as numbers by Excel were returned as numbers when the CONCATENATE function is used.
How to fix it?
To fix it, we need to use the Excel TEXT function. The formula to be used would be:
4. Adding zeros before numbers with variable lengths
We all know any zero’s added before numbers are automatically removed by Excel. However, if we need to keep those zeros then the TEXT function comes handy. Let’s see an example to understand how to use this function.
We are given a 9-digit product code, but Excel removed the zeros before it. We can use TEXT as shown below and convert the product code into a 9-digit number:
In the above formula, we are given the format code containing 9-digit zeros, where the number of zeros is equal to the number of digits we wish to display.
5. Converting telephone numbers to a specific format
If we wish to do the same for telephone numbers, it would involve the use of dashes and parentheses in format codes.
Here, I want to ensure the country code comes in brackets (). Hence the formula used is (##) ### ### ###. The # is the number of digits we wish to use.
To learn more, launch our free Excel crash course now!
Format Code
It is quite easy to use TEXT Function in Excel but it works only when the correct format code is provided. Some frequently used format codes include:
Code | Description | Example |
---|---|---|
# (hash) | It does not display extra zeros | #.# displays a single decimal point. If we input 5.618, it will display 5.6. |
0 (zero) | It displays insignificant zeros | #.000 would always display 3 decimals after the number. So if we input 5.68, it will display 5.680. |
, (comma) | It is a thousand separator | ###,### would put a thousands separator. So if we input 259890, it will display 259,890. |
If the Excel TEXT function isn’t working
Sometimes, the TEXT function will give an error “#NAME?”. This happens when we skip the quotation marks around the format code.
Let’s take an example to understand this.
If we input the formula =TEXT(A2, mm-dd-yy). It would give an error because the formula is incorrect and should be written this way: =TEXT(A2,”mm-dd-yy”).
Tips
- The data converted into text cannot be used for calculations. If needed, we should keep the original data in a hidden format and use it for other formulas.
- The characters that can be included in the format code are:
+ | Plus sign |
— | Minus sign |
() | Parenthesis |
: | Colon |
{} | Curly brackets |
= | Equal sign |
~ | Tilde |
/ | Forward slash |
! | Exclamation mark |
<> | Less than and greater than |
- TEXT function is language-specific. It requires the use of region-specific date and time format codes.
Free Excel Course
Check out our Free Excel Crash Course and work your way toward becoming an expert financial analyst. Learn how to use Excel functions and create sophisticated financial analysis and financial modeling.
Additional Resources
Thank you for reading CFI’s guide on the Excel TEXT Function. To keep learning and advancing your career, the following resources will be helpful:
- Excel Functions for Finance
- Advanced Excel Formulas Course
- Advanced Excel Formulas You Must Know
- Excel Shortcuts for PC and Mac
- See all Excel resources
Article Sources
- TEXT Function
Excel TEXT Function (Example + Video)
When to use Excel TEXT Function
Excel TEXT function can be used when you want to convert a number to text format and display it in a specified format.
What it Returns
It returns text in the specified format.
Syntax
=TEXT(value, format_text)
Input Arguments
- value – the number that you want to convert into text.
- format_text – the format in which you want to display the number.
Additional Notes
- This is a useful function when there is a need to show numbers in a format, or a need to combine numbers with text/symbols.
- For example, if you have a value 2000 in cell A1. and you want to show the text – The Sales were $2,000, you can use the following formula: =”The Sales were “&TEXT(A1,”$#,###”)
- The numbers are converted to text, and hence can not be used in calculations.
- If you need to use these numbers in formulas/calculations, use custom number formatting.
Excel TEXT Function – Live Example
Excel TEXT Function – Video Tutorial
Related Excel Functions:
- Excel CONCATENATE Function.
- Excel LEFT Function.
- Excel LEN Function.
- Excel MID Function.
- Excel REPT Function.
- Excel RIGHT Function.
- Excel TRIM Function.
You may also like the following Excel tutorials:
- How to Remove Time from Date in Excel
- How to Convert Serial Numbers to Dates in Excel
- How to Convert Numbers to Text in Excel
На чтение 1 мин
Функция TEXT (ТЕКСТ) в Excel используется для преобразования числа в текстовый формат и отображения его в специальном формате.
Содержание
- Что возвращает функция
- Синтаксис
- Аргументы функции
- Дополнительная информация
- Примеры использования функции ТЕКСТ в Excel
Что возвращает функция
Текст в заданном формате.
Синтаксис
=TEXT(value, format_text) — английская версия
=ТЕКСТ(значение, которое нужно отформатировать; «код формата, который требуется применить») — русская версия
Аргументы функции
- value (значение, которое нужно отформатировать) — число для преобразования в текст;
- format_text (код формата, который требуется применить) — формат для отображения числового значения.
Дополнительная информация
- Это очень полезная функция в тех случаях, когда нужно показать числа в каком-то формате или комбинировать числа и текст. Например, представим, что у нас в ячейке А1 есть число «3333» и нам надо использовать его в тексте «Продажи составили $3,333». В этом нам поможет формула:
=»Продажи составили «&TEXT(A1,»$#,###») — английская версия
Больше лайфхаков в нашем Telegram Подписаться
=»Продажи составили «&ТЕКСТ(A1;»$#,###») — русская версия
- Числа, преобразованные в текст не могут быть использованы для дальнейших вычислений;
- Если вы хотите использовать числа в формулах/вычислениях, используйте формат числового значения.
Примеры использования функции ТЕКСТ в Excel
If you want to add a number to a text string, you can’t do so directly since the format isn’t maintained. Also, a number added to a text string doesn’t have any formatting or all its decimal places.
The TEXT
function comes in handy here, as it allows you to convert a number to text format with a specific formatting. Then you can add it to another string, and it’ll be in the format you want.
How to Use the TEXT
Function in Excel
Let’s say you have a series of numbers, and you want to write a message including those numbers.
Let’s take a look what happens first without using the TEXT function. First, we’ll try to use the CONCAT
function as =CONCAT("In ", A2, " there was a profit of ", B2)
and then populate the rest of the column with the same formula.
It doesn’t look very good, and the numbers are all different from each other. This is because when we concatenate a number to a string, the format is lost.
So instead, let’s use TEXT
to make a string of the number, and then add it to the string.
TEXT
takes two arguments: the first one is the number we want to convert to a string, and the second is the format. In this case the format we’ll use is $##,##0.00
(we will see later how to create the format we want).
Let’s delete all the content of column C and title it instead Profit in string format
. We’ll write in C2 =TEXT(B2, "
, and then expand it to the rest of the column.$##,##0.00
")
If you create the string again using the number in string format, this time the numbers stay in the format you want.
How to Use Different Number Formats in Excel
We just saw how to use one specific format, $##,##0.00
. Now let’s see what the characters mean so you can use the number format you wish. Also note that the decimal numbers are rounded when the format shows fewer decimal places than what the numbers have.
How to Format Numbers as Decimals
The 0
is for a number that must be there – if the converted number does not have enough places, there will be a 0
. You can use this to decide how many decimal places, trailing 0
s, or leading 0
s to show.
For example the number 12345.6
with a format of 000000
will be shown as 012345
with a leading 0
. But if it’s formatted as 0.00
, it will be shown as 12345.60
with a trailing 0
.
The #
is for a number that could be there but also could not be. You can use it, for example, to show how many decimal numbers to show max.
For example 12345.6
formatted as 0.###
will be shown as 12345.6
. But 12345
will be shown as 12345.
, and 12345.6789
will be shown as 12345.679
, as the format is for a max of 3 decimal places.
You can add other characters at the beginning, in the middle, or at the end. You can add any characters except ,
, .
, ?
, 0
, and #
. The comma acts as the thousands separator, the dot is a decimal separator, and the last three symbols have special meaning in the formatting (for example, the ?
is used in fractions, see below).
Here are a few examples:
How to Format Numbers as Fractions
You can also format numbers as fractions. In the fraction format, you can indicate how many digits the denominator should have (or specify a denominator). You can also specify if the whole part has to be written inside the fraction or separated.
To specify the number of digits in the denominator of the fraction, you can use the ?
character. You use as many in the denominator as the number of digits you want there.
So for example ?/?
is for one digit in the denominator, ??/??
is for two digits, and so on (note that you get the same result with ?/??
or with ??/??
).
To specify which number has to be the denominator you can write it into the format. So if you want a fraction in ninteenths, you can write ??/19
.
To separate the whole part from the fraction you can write a #
in front of it separated by a space, so # ??/19
or # ???/???
. And if you want the whole part always visible even if it’s zero, you can write 0 ??/19
or 0 ???/???
instead.
Conclusion
Adding numbers inside strings is often useful in writing reports. But if you want to keep the number in a specific format, you need to use the TEXT
function.
In this article you have learned how to format a number as an integer, as a number with decimal places, or as a fraction.
Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started