The tutorial shows how to use the VALUE function in Excel to convert text strings to numeric values.
Normally, Microsoft Excel recognizes numbers stored as text and converts them to the numerical format automatically. However, if the data is stored in a format that Excel cannot recognize, numeric values can be left as text strings making calculations impossible. In such situations, the VALUE function can be a quick remedy.
Excel VALUE function
The VALUE function in Excel is designed to convert text values to numbers. It can recognize numeric strings, dates and times.
The syntax of the VALUE function is very simple:
Where text is a text string enclosed in quotation marks or a reference to a cell containing the text to be changed to a number.
The VALUE function was introduced in Excel 2007 and is available in Excel 2010, Excel 2013, Excel 2016 and later versions.
For example, to convert text in A2 to number, you use this formula:
In the screenshot below, please notice the original left-aligned strings in column A and the converted right-aligned numbers in column B:
How to use VALUE function in Excel - formula examples
As pointed our earlier, in most situations Excel converts text to numbers automatically when necessary. In some situations, however, you need to explicitly tell Excel to do so. The below examples show how this works in practice.
VALUE formula to convert text to number
You already know that the main purpose of the VALUE function in Excel is to change text strings to numeric values.
The following formulas give some ideas of what kind of strings can be turned into numbers:
|=VALUE("$10,000")||10000||Returns a numeric equivalent of the text string.|
|=VALUE("12:00")||0.5||Returns the decimal number corresponding to 12 PM (as it is stored internally in Excel.|
|=VALUE("5:30")+VALUE("00:30")||0.25||The decimal number corresponding to 6AM (5:30 + 00:30 = 6:00).|
The screenshot below shows a few more text-to-number conversions performed with the same VALUE formula:
Extract number from text string
Most Excel users know how to extract the required number of characters from the start, end or middle of a string - by using the LEFT, RIGHT and MID functions. When doing so, you have to remember that the output of all these functions is always text, even when you are extracting numbers. This may be irrelevant in one situation, but critical in another because other Excel functions treat the extracted characters as text, not numbers.
As you can see in the screenshot below, the SUM function is not able to add up the extracted values, though at first sight you may not notice anything wrong about them, maybe except for the left alignment typical for text:
In case you do need to use the extracted numbers in further calculations, wrap your formula into the VALUE function. For example:
To extract the first two characters from a string and return the result as a number:
To extract two characters from the middle of a string beginning with the 10th char:
To extract the last two characters from a string as numbers:
The above formulas not only pull the digits, but also perform the text to number conversion along the way. Now, the SUM function can calculate the extracted numbers without a hitch:
Of course, these simple examples are mostly for demonstration purposes and for explaining the concept. In real-life worksheets, you may need to extract a variable number of digits from any position in a string. The following tutorial shows how to do this: How to extract number from string in Excel.
VALUE function to convert text to dates and times
When used on dates/times text strings, the VALUE function returns a serial number representing the date or/and time in the internal Excel system (integer for date, decimal for time). For the result to appear as a date, apply the Date format to the formula cells (the same is true for times). For more information, please see Excel date format.
The screenshot below shows possible outputs:
Also, you can use the alternative ways to convert text to dates and times in Excel:
To convert date values formatted as text to normal Excel dates, use the DATEVALUE function or other ways explained in How to convert text to date in Excel.
To convert text strings to time, use the TIMEVALUE function as shown in Convert text to time in Excel.
Why Excel VALUE function returns #VALUE error
If a source string appears in a format not recognized by Excel, a VALUE formula returns #VALUE error. For example:
How do you fix this? By using more complex formulas described in How to extract number from string in Excel.
Hopefully this short tutorial has helped you to gain understanding about using the VALUE function in Excel. I thank you for reading and hope to see you on our blog next week!
Practice workbook for download
Excel VALUE formula - examples (.xlsx file)