How to use the VALUETOTEXT function
What is the VALUETOTEXT function?
The VALUETOTEXT function returns a value in text form. Text values are unmodified and non-text values are converted to text.
Table of Contents
1. Introduction
What is a text value?
Excel has three different types of values: Text, numbers, and Boolean values. Excel tries to identify values you enter in a cell and sometimes it gets it wrong.
Excel shows what kind of value it is by aligning the value to the right, center or left.
What are dates and time values?
They are also numbers but formatted differently. The image below demonstrates different values in Excel.
- Cell B3 contains a text value, it is left-aligned in the default setting.
- Cell B4 contains a whole number, it is right-aligned in the default setting.
- Cell B5 contains a boolean value, it is centered in the default setting.
- Cell B6 contains a rational number, it is also right-aligned in the default setting.
- Cell B7 contains a boolean value, it is centered in the default setting.
- Cell B8 contains an error value, it is centered in the default setting.
- Cell B9 contains a time value which is a number formatted as a time value, it is right-aligned in the default setting.
- Cell B10 contains a date value which is a number formatted as a date value, it is right-aligned in the default setting.
What is the difference between VALUETOTEXT function and ARRAYTOTEXT function?
The VALUETOTEXT function is for converting individual values to text while the ARRAYTOTEXT joins arrays or values in a cell range into an output text string.
Use the VALUETOTEXT function if you want to convert a single value and the ARRAYTOTEXT function if you want to convert multiple values.
2. Syntax
VALUETOTEXT(array, [format])
array | A cell reference or an array. |
[format] | Optional. This argument lets you change the output format.
0 - Default. Concise format, the returned value has general formatting applied. 1 - Strict format, includes escape characters. Encloses all values with quotes except for errors, numbers, and boolean values. |
3. Example 1
This example shows the VALUETOTEXT function with a 0 (zero) as the second argument meaning concise format. Note, all values in column D are converted to text and are automatically left-aligned in the cells.
Formula in cell D3:
Cell B3 contains "How are you?" which is a text value. The VALUETOTEXT function in cell D3 converts it to a text value, in this case, it is already a text value.
Formula in cell D4:
Cell B4 contains 5, which is a numeric value. The VALUETOTEXT function in cell D4 converts it to a text value "5" without double quotes.
Formula in cell D5:
Cell B5 contains TRUE, which is a logical value. The VALUETOTEXT function in cell D5 converts it to a text value "TRUE" without double quotes.
Formula in cell D6:
Cell B6 contains 3.12, which is a numeric value. The VALUETOTEXT function in cell D6 converts it to a text value "3.12" without double quotes.
Formula in cell D7:
Cell B7 contains FALSE, which is a logical value. The VALUETOTEXT function in cell D7 converts it to a text value "FALSE" without double quotes.
Formula in cell D8:
Cell B8 contains #N/A, which is an error value. The VALUETOTEXT function in cell D8 converts it to a text value "#N/A" without double quotes.
Formula in cell D9:
Cell B9 contains 5:42 AM, which is a time value. The VALUETOTEXT function in cell D9 converts it to a numeric value representing the fraction of a day, displayed as "0.2375" without double quotes.
Formula in cell D10:
Cell B10 contains 1/2/2025, which is a date value. The VALUETOTEXT function in cell D10 converts it to a numeric value representing the number of days since January 1, 1900, displayed as "45659" without double quotes.
4. Example 2
This example demonstrates how the VALUETOTEXT function returns values in strict form. Text values have leading and trailing double quotes, remaining values are unchanged.
Formula in cell C3:
The text "ZF" in cell B3 is transformed by the VALUETOTEXT function in C3. This function, with its two parameters (array and format), employs the strict format to encase the original text within double quotation marks.
Formula in cell C5:
Cell C5 displays the result of the VALUETOTEXT function applied to the number 5 from B5. The strict format used in this function preserves numeric values without adding quotation marks.
Formula in cell C6:
In C6, we see the outcome of VALUETOTEXT processing "T5" from B6. The function's strict format parameter ensures that this text input is returned enclosed in double quotes.
Formula in cell C8:
The error value "#N/A" in B8 remains unchanged when processed by VALUETOTEXT in C8. The function's strict format leaves error values intact, without adding quotation marks.
Formula in cell C9:
VALUETOTEXT in C9 processes the text "SK" from B9. Using the strict format, it returns the input surrounded by double quotation marks.
Formula in cell C10:
Similarly, cell C10 shows "JK" in quotes, resulting from VALUETOTEXT's strict format application to the text in B10.
Formula in cell C12:
Cell B12 contains "DP" which is a text value. The VALUETOTEXT function in cell C12 has two arguments, array and [format]. This example uses the strict format which converts the source data to a text value enclosed in double quotes.
Formula in cell C13:
Cell B13 contains 3 which is a numeric value. The VALUETOTEXT function in cell C13 has two arguments, array and [format]. This example uses the strict format which leaves the numeric value as is without enclosing it in quotes.
Formula in cell C14:
Cell B14 contains "#DIV/0!" which is an error value. The VALUETOTEXT function in cell C14 has two arguments, array and [format]. This example uses the strict format which leaves the error value as is without enclosing it in quotes.
5. Function not working
VALUETOTEXT returns a #VALUE! error if the second argument [format] is larger than 1 or smaller than 0 (zero).
The second argument in the formula in cell D3 is 2, the VALUETOTEXT function returns #VALUE! shown in the image above.
A #NAME! error is displayed if you misspelled the VALUETOTEXT function.
5.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
5.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference C3 converted to hard-coded value using the F9 key. The VALUETOTEXT function requires numerical values equal to 0 (zero) or 1 in the second argument which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
5.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
Useful links
VALUETOTEXT function - Microsoft support
VALUETOTEXT
Functions in 'Text' category
The VALUETOTEXT function function is one of 29 functions in the 'Text' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form