The Excel Text function converts a supplied numeric value into text, in a user-specified format.
The syntax of the function is:
Where the function arguments are:
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. |
The format definitions that can be used in the Excel Text function are shown in the table below. These definitions have the same meaning when used in the custom style of Excel Cell Formatting.
0 | - | Forces the display of a digit in its place |
# | - | Display digit if it adds to the accuracy of the number (but don't display if a leading zero or a zero at the end of a decimal) |
. | - | Defines the position that the decimal place takes |
d | - |
|
m | - |
|
y | - |
|
h | - |
|
m | - |
|
s | - |
|
AM/PM | - | Indicates that a time should be represented using a 12-hour clock, followed by "AM" or "PM" |
The following spreadsheet shows the Excel Text function, used to apply different formatting types to various numeric values.
Formulas:
|
Results:
|
Note that the results returned from the Text function are all text values.
One of the most common uses of the Excel Text function is to insert dates into text strings.
Without the use of the Text function, the simple concatenation of a date returns the date's underlying integer value. This is shown in the example below:
Formulas:
|
||||||||||||||||||||
Results:
|
For further details and examples of the Excel Text function, see the Microsoft Office website.
Some users have problems when the Excel Text function returns the #NAME? error:
#NAME? | - |
This is returned from the Excel Text function, if you omit the quotation marks from around the format_text argument. For example, the formula
=TEXT( A2, mm/dd/yyyy )
will return the #NAME? error. Solution: Add quotes around the formatting definition. E.g. the above example would be corrected as:
=TEXT( A2, "mm/dd/yyyy" )
|