A common frustration in Excel is when numbers are stored as text.
You will not be able to perform Excel tasks such as mathematical calculations, create charts from the values, or group them into ranges while the numbers are stored as text.
In this tutorial, you will learn how to recognize numbers stored as text and multiple ways to convert text to numbers.
Here’s what we’ll cover:
- How to check if a value is numeric or text
- The ‘Convert to Number’ Excel option
- Change text to numbers with Paste Special
- Using Text to Columns to convert text
- Convert text to numbers using formulas
You can follow along with this workbook.
1. How to check if a value is numeric or text
It is not always clear that a number is stored incorrectly. It can appear as a number, yet be stored as text. This causes much confusion for Excel users.
However, there are some things to look out for, and ways to accurately check it.
Firstly, Excel will always display text to the left of a cell and numeric values to the right of a cell. So, if a value is left-aligned, it is probably text.
This is just a clue and not guaranteed, because users can change the alignment of cell values. However, it is a great place to start and a good clue to look out for.
Another way of checking is to select the range of values and look at the calculations down on the Status Bar.
If the values are all numeric, you will probably see average, count and sum calculations. And if any are text, only the count is performed.
Once again, these calculations can be changed by users so it’s not a perfect check. However, it will work 95% of the time and is a fast and easy way of checking.
To be completely sure, we can use an Excel function named ISNUMBER. This function will return TRUE if the value is numeric and FALSE if it is not.
You only need to provide the ISNUMBER function with the value to check. In this example, the following formula was entered into cell C2.
I have converted some of the values to numbers. So, even though they all look like numbers, the ISNUMBER formula returns FALSE, making it easy to identify the problem values.
2. The ‘Convert to Number’ Excel option
The first technique we will look at to convert text to numbers is the ‘Convert to Number’ option provided in Excel.
It is quick and simple, but it is unfortunately not always available to you.
This option is available when numbers are stored as text as a result of downloading the data from a website or some database, or maybe copied and pasted between programs.
Also, it may be that someone accidentally typed an apostrophe before the number. This tells Excel to store the number as text, and is very useful for entering ‘fake’ numbers such as phone numbers and ID numbers.
A green triangle is shown in the top left corner of the cell if this option is available to you.
This triangle means that the value has failed one of Excel’s error check rules, and is used to identify other errors outside of just recognizing numbers stored as text.
To convert to numbers;
- Select the range of cells to change.
- Click the exclamation mark icon and click Convert to Number.
The values are converted. The green triangle has disappeared and the values are now right aligned. This is how we expect to see numbers.
3. Change text to numbers with Paste Special
Paste Special in Excel is a fabulous tool. It is no surprise that it can help us convert text to numbers too.
To do so, we need to use Paste Special to perform a simple calculation. When a text value is used in a calculation, the result is numeric.
- Type the number 1 in a cell, any cell.
- Copy that cell value.
- Select the range of values you need to convert to numbers.
- Click Home > Paste list arrow and Paste Special.
5. Select Values and the Multiply operation. Click Ok.
4. Using Text to Columns to convert text
Text to columns is another great way to quickly convert text to numbers.
- Select the range of values.
- Click Data > Text to Columns.
- Step 1 of the Text to Columns wizard regards splitting text between columns. We do not need this, so click Next.
4. In step 2 remove all delimiter checkboxes.
5. Step 3 asks about the value formatting. Leave it as General (the date option is great when working with date values). Click Finish.
You probably didn’t change an option during the Text to Columns process, and we could have clicked Finish before step 3.
However, you may have to consider if your value contains delimiters such as spaces or commas.
I like this method of converting text to numbers. It is quick and simple.
5. Convert text to numbers using formulas
The previous methods are great, but they require manual intervention. A user will need to perform the steps to convert the text to numbers.
With a formula, we can automate the solution. It will not change the value in the cell containing text, but rather, create a clean version in another cell.
If the data is regularly changed, a formula will ensure that the values fed to a PivotTable, chart or other formulas continue to be numeric. And no manual intervention is required.
Using a formula is also great for combining with other functions. For example, converting results from text functions into numbers.
That is the example we will look at here.
In this example, we have data downloaded from a source and the values in column B are stored as text due to the dollar sign.
Using a formula, the number has been extracted successfully. However, the RIGHT and LEN functions used in the formula are text functions. So, the result is returned as text.
The VALUE function of Excel converts text that represents a number to a number.
Using this function, the result of the RIGHT function is converted from text to number.
The values can then be formatted as required. For example, in the accounting format with the dollar sign.
Final thoughts and further reading
So there you have it: some simple methods for converting text to numbers. If you’re getting to grips with Excel in your quest to become a data analyst, you can try a free data analytics short course here. Keen to learn more Excel functions? Check out the following: