Why the numbers are stored as text
Excel stores a value as text when it was pasted from another program, imported from a file, or typed with a leading apostrophe. Text that looks like a number is left-aligned by default and often shows a small green triangle. Functions such as SUM skip text values, so a column of text numbers can add up to the wrong total. Converting them is usually worth the effort.
Use VALUE
VALUE turns text that looks like a number into a number. If cell A1 holds the text 42, this formula returns the number 42:
=VALUE(A1)
If the text isn’t a number, VALUE returns #VALUE!.
Use a double negative
Two minus signs in front of a cell reference also convert text to a number:
=--A1
Each minus sign negates the value, so the pair cancels out, and Excel converts the text to a number along the way. It works, but many people find VALUE easier to read.
Multiply or add zero
Formulas like =A1*1 or =A1+0 also make Excel treat the text as a number. For plain numbers they give the same result as the double negative. Use whichever one is easiest for you to read.
Convert a whole range
You don’t need a formula to convert many cells at once.
To use Paste Special:
- Type
1in an empty cell and copy it. - Select the text cells you want to convert.
- Choose Home, then Paste, then Paste Special. Select Multiply and click OK.
- Delete the
1you typed.
To use Text to Columns:
- Select the column of text.
- On the Data tab, choose Text to Columns.
- Click Finish without changing the settings. If the column uses the General format, Excel often converts the text to numbers.
If Excel flags cells with green triangles, select them, click the warning icon that appears, and choose Convert to Number.
Regional separators
VALUE reads numbers according to your computer’s regional settings. A text value like 3,5 means three and a half in some regions and something else in others. NUMBERVALUE, available in Excel 2013 and later, lets you state the separators:
=NUMBERVALUE("1.234,5", ",", ".")
This returns 1234.5, because the comma is the decimal separator and the period groups the thousands.
Leading zeros and long numbers
Converting 00123 gives 123. If the leading zeros matter, such as in ZIP codes or product codes, keep those values as text. Excel also keeps only about 15 significant digits, so long ID numbers can lose their last digits when they’re converted.
Quick comparison
| Method | How to use it | Notes |
|---|---|---|
| VALUE | =VALUE(A1) |
Easy to read; returns #VALUE! for non-numbers |
| Double negative | =--A1 |
Short, but harder to read |
| Multiply | =A1*1 |
Works for plain numbers |
| Paste Special | Multiply by 1 | Overwrites the original cells |
| Text to Columns | Data tab, then Finish | Converts a whole column |
| Convert to Number | Warning icon menu | Fast for flagged cells |
Doing it in code
The same job in a program uses different tools. C++ gives you functions such as std::stoi for this. For the code version, see c convert string to int.