The TEXT function is a frequently used feature in Excel, designed to convert numerical values into specific text strings with formatting. To delve deeper into the formula and efficient utilization of the TEXT function in Excel, follow this article from Mytour.
What is the TEXT Function?
The TEXT function is widely employed to transform numbers into text with specific formatting. Using the TEXT function makes numerical values more readable and user-friendly. Additionally, it is utilized to combine numerical values with text or symbols.
The TEXT function is used to combine text with numerical values or symbolsFormula for Using the TEXT Function
When using the TEXT function in Excel, users rely on the syntax as follows:
TEXT(value, format_text)
Value: The numerical values you want to convert into text or specific characters.
format_text: This is a string of text along with the formatting you want to apply to the value. The format code is enclosed in double quotation marks.
Considerations when using the TEXT function
Using the TEXT function to convert numbers into text can complicate performing calculations in Excel. This is because the result of the TEXT function is always a text string, even though it may resemble a numerical value.
It's advisable for users to keep the original value in one cell in Excel before applying the TEXT function to another cell. This allows you to reference the original value anytime, preventing potential confusion that could impact the results.
Some types of format codes for the TEXT function
| Công thức | Mô tả |
| =TEXT(5521.467,"$#,##0.00") | Sử dụng cho việc tách phần nghìn và 2 số thập phân trên tiền tệ. Kết quả sẽ trả về tương ứng $5,521.47 (Excel sẽ tự động làm tròn giá trị đến 2 chữ số thập phân”). |
| =TEXT(TODAY(),"MM/DD/YY") | Để định dạng ngày tháng, ví dụ như ngày hôm nay là 12/06/2022. |
| =TEXT(TODAY(),"DDDD") | Để định dạng ngày thứ trong tuần, ví dụ như ngày hôm nay là Thứ 3. |
| =TEXT(NOW(),"H:MM SA/CH") | Để định dạng múi giờ hiện tại, ví dụ như bây giờ là 10:50SA. |
| =TEXT(0.525,"0,0%") | Để định dạng các con số thành phần trăm, ví dụ như 52.5%. |
| = TEXT (5.2,"#?/?") | Để định dạng dữ liệu thành phân số, ví dụ như kết quả của 5.2 là 26/5. |
| =TRIM(TEXT(0,34,"# ?/?")) | Để định dạng dữ liệu thành phân số, ví dụ như 1/3. Điểm khác biệt của công thức này là sử dụng hàm TRIM để có thể loại bỏ dấu cách ở đầu dòng bằng một giá trị thập phân. |
| =TEXT(28400000,"0.00E+00") | Để định dạng dữ liệu thành ký hiệu khóa học. Ví dụ như 2.84E + 07. |
| =TEXT(234567,"0000000") | Để thêm số 0 đứng trước dãy số. Ví dụ như 0234567. |
| =TEXT(165233,"##0° 00' 00''") | Tùy chỉnh - Vĩ độ/Kinh độ địa lý |
Examples of using the TEXT function
Linking text and numbers (dates) with custom formatting
To create a summary or report, beyond performing operations like summing, percentage calculations, and similar figures, users also need to explain the main significance of these values. To achieve this, users should use the Concatenate function to input text and numbers combined with the TEXT function to format numbers (or dates) as desired.
Adding number formatting within a text string
Aiming to calculate the total amount to be paid with the following data:
Calculate the total before applying the TEXT function in ExcelTo achieve the result, follow these steps:
Total = Unit Price * Quantity * % (subtract % discount)
If you perform the normal calculation, simply input =A2*B2*(1-C2). Excel will automatically compute and provide the result as 156.8.
But a mere number doesn't convey much. You need units, formatting, or annotations for easy comprehension.
For a clearer view, just insert some annotations like 'Total:' before the price item. To make the amount vivid, you can insert symbols such as $ or thousands separators and decimal places.
You can use the TEXT function in one of two ways:
Method 1: Concatenate a text string with symbols using the TEXT function.
='Total: '&TEXT(A2*B2*(1-C2),'$###,###.00')
Total when applying the TEXT function with various formats, attractive characters, and better understandingMethod 2: Use CONCATENATE function combined with TEXT function to concatenate character strings.
Perform the following steps:
=CONCATENATE (text1, text2,…).
Where text1 and text2 are text strings, values within the formula, or cell references.
To execute the example above, you need to proceed as follows:
=CONCATENATE('Total: ',TEXT(A2*B2*(1-C2),'$###,###.00'))
Total when applying a combination of TEXT and CONCATENATE functions in ExcelLinking text with date
Suppose you have data and want to add the note 'Date of data initialization:' with date values displayed as Day, Month, Year (Example: 16/06/2022).
To achieve this, you simply incorporate the TODAY function into the TEXT formula specifying the format 'dd/mm/yyyy'. There are two approaches:
Approach 1: Utilize predefined symbols to concatenate text strings with the TEXT function:
='Date of execution: ' & TEXT(TODAY(), 'dd/mm/yyyy')
Combine TEXT and TODAY functions to concatenate text strings with the date in EXCELMethod 2: Combine CONCATENATE with the TEXT function
=CONCATENATE('Date of execution: ', TEXT(TODAY(), 'dd/mm/yyyy'))
Utilize CONCATENATE with TEXT and TODAY functions to concatenate text strings with the date in ExcelInserting leading zeros to number sequences
Results from this method will be text strings and can't be used for further calculations as they are not numeric values.
Numbers in the column have leading zeros added
The TEXT function is employed to add leading zeros to numbers in a column so that they share the same numerical unit.
=TEXT(A2,'000000')
Adding leading zeros to number sequences in a column using the TEXT functionAdding zeros to phone number data
Numbers without leading zeros in phone numbers are often automatically removed by Excel, causing difficulties in verification or contact. To add zeros to this data, users need to perform the following operation:
='0'&TEXT(C2, '#### ### ###')
Add zeros to the phone number sequence in Excel using the TEXT functionNote when using: Phone number data needs to have the same number of digits (a 10-digit phone number will be processed with 10 digits, an 11-digit phone number will be processed with 11 digits).
Transform phone numbers into different formats
You can use special characters such as '-' or '()' with the TEXT function in Excel to apply specific formatting to your work.
For example, if phone numbers need an area code at the beginning, you can set it up like this:
=TEXT(A2,'[<=9999999]### ####;(###) ### ####')
Utilize the TEXT function to transform phone number data into a different formatCommon errors when using the TEXT function in Excel
Excel formulas require precise manipulation down to each character. Therefore, errors during operations are inevitable. Let's explore some common errors with Mytour!
Error #NAME? when using the TEXT function in Excel
The #NAME? error often occurs when users forget to add double quotes. The solution is simple:
Double-check the formula and add double quotes from =TEXT(D2,mm/dd/yy) to =TEXT(D2,'mm/dd/yy').
Encountering the #NAME? error is a common issue when using the TEXT function in ExcelError due to incorrect syntax in Excel
There are two main reasons leading to syntax errors in Excel
Cause 1: It may result from users entering the formula incorrectly or copying a formula from elsewhere with improperly formatted quotes. Typically, Excel will display There's a problem with this formula.
Users can rectify this by manually retyping the formula to ensure correct formatting.
Cause 2: It may be due to differences in language settings in Excel across different countries. For instance, Excel in Germany:
Typically, users in Vietnam might input =TEXT(A1,”mm/dd/yy”) while users in Germany would need to input =TEXT(A1;”mm/tt/jj”).
This article covers everything users need to know when utilizing the TEXT function in Excel. We hope you can apply these tips in your work. If you have any further questions, feel free to leave a comment for Mytour to address. Thank you for reading.
