Why does Excel treat long numeric strings as scientific notation even after changing cell format to text

121

22

I'm trying to process some data in Excel. The data includes numeric account numbers and other long numeric strings (like cell phone MEIDs). I am not doing math operations on these strings, so I want Excel to treat them as plain text.

Here is what is making me nuts (this is Excel 2010):

  1. Take a long number like 1240800388917 and paste it in a cell in a new worksheet.
  2. Excel's default cell format is general, so the string is presented in scientific notation as 1.2408E+12
  3. Right click on the cell, select Format Cells, set the format to Text

The cell is still displayed in scientific notation, even though the format has been set to text.

Now, if I do the steps in a different order:

  1. Format an empty cell as text. Right click on the cell, select Format Cells, set the format to Text
  2. Take a long number like 1240800388917 and paste it in to the text formatted cell

Now, the cell is displayed as a string and not in scientific notation.

The results remaining in scientific notation even though the cell is formatted as text just seems broken to me. I've seen suggested work-arounds like: use CSV import and set the format to text, add a space character to the beginning of each numeric string, and others.

Is there a simple good work around to easily keep these strings formatted as text?

Why on earth does Excel do this?

Related SU questions I found: How can you make Excel 2007 stop formatting large numbers as scientific notation? and Is this Excel behaviour with a large hex number expected?

Michael Levy

Posted 2012-04-16T20:39:25.353

Reputation: 1 480

The long number 1240800388917 is copied from another cell? Or just plain text, like from Notepad? – wilson – 2012-04-17T06:56:52.607

Answers

23

Ah, memories of data munging back from when I did some massive number cross checking in Excel (never again).. When you punch in long numeric strings into Excel, try say, 12345678901234567890 (20 digits), Excel will generally convert it for you, meaning that the 20 digit number you've just tapped in has been cut back to be only about fifteen significant figures.

Note as well: the conversion is a truncation, as opposed to rounding. (12345678901234567890 is 1.23456789012346E+19, but excel will show you 1.23456789012345E+19)

This occurs at point of entry, so once it's in, any additional detail is lost, and so even if you tell Excel that you really meant that was text, and not a number, you're kind of out of luck, and hence why your first sequence doesn't work.

tanantish

Posted 2012-04-16T20:39:25.353

Reputation: 1 103

11Quick Hack: Set formatting on appropriate columns, copy paste to notepad, then to Excel. – Brian – 2015-02-18T19:08:56.800

I solved this problem by setting the cell format to "Text" before pasting data into Excel (similar to what @Brian said in another comment). – Derek Kurth – 2017-07-28T13:49:23.907

11This should NOT BE THE ACCEPTED ANSWER: see the next one below. – javadba – 2018-05-03T13:23:57.433

4So you've reminisced and reiterated the problem. Now, how do you fix it? – user3932000 – 2018-11-25T22:27:17.753

+1 for this one because it clearly describes the data truncation issue. – wanghq – 2020-01-17T19:10:37.867

1Yes, I see that behavior when my numeric string has more than 15 significant digits. 12345678901234567890 becomes 1.23456789012345E+19 as you say. When I click on the cell, the edit box shows the string truncated and padded with zeros as 12345678901234500000. What is odd is that it does the same thing for numbers that don't overflow excel's 15 digit limit. If I paste in 12345678901234, it is displayed as 1.23457E+13, but when I click it the edit box still shows the original string. Now, what is odd is if I format this cell to text, it still shows in scientific notation. Annoying. – Michael Levy – 2012-04-17T14:39:06.057

7That one is a little bit of a display quirk actually - setting the format from general to text wont immediately show it as the original string, but if you go in and edit the data (as in, just click into the edit zone and click out) it'll update to be exactly what you put in. – tanantish – 2012-04-17T17:27:44.123

If I click on the cell I can see that excel has the entire number, but regardless if I make all the cells text it still wants to use scientific notation. So frustrating! – The Muffin Man – 2013-06-26T01:10:26.203

171

This worked for me in Excel 2010. Just select the column, right click, Format cells, Custom and choose the option that says 0 (second option below General).

Anonymous

Posted 2012-04-16T20:39:25.353

Reputation: 1 743

26This is so much better than the accepted answer which says "you're kind of out of luck"! I had a CSV file which had this problem, and the custom formatting solution worked perfectly. – davidair – 2015-04-17T19:48:41.797

4must be accepted answer, someone should/could change? – qwertzman – 2015-07-09T10:14:18.820

13This still appears to truncate in my test. Using Excel 2013 I entered the following into a cell 12345678901234567890. When I hit enter this is displayed as 1.23457E+19 and the underlying value is changed to 12345678901234500000 so there is data loss. This doesn't answer the original question. – Michael Levy – 2015-10-21T22:31:32.260

The problem is that your numbers aren't formatted as text, but as number when you try this. And that opens a whole lot of other caveats. – Joris Meys – 2016-01-11T09:41:23.517

1Here I am a year later revisiting the same answer and wishing I could upvote it again. – billynoah – 2017-01-26T06:05:49.380

8

This answer fixes the formatting, but does not preserve the entered data. That is why I cannot accept it as a correct answer. I posted a short video to show. When you follow these directions, and then enter a long integer like 12345678901234567890 you lose precision when treating it as numeric, even if it is displayed in non-scientific notation. Excel treats it as the value 12345678901234500000. Only by treating it as text can you maintain all the digits. See https://youtu.be/7EDcR7TQpYs

– Michael Levy – 2018-09-22T22:34:20.083

This seems to only work for me if I do this to the column prior to pasting in vals. – twknab – 2019-09-30T18:48:48.500

13

A single apostrophe ' before a number will force Excel to treat a number as text (including a default left align). And if you have errors flagged, it will show as a number stored as text error on the cell.

dav

Posted 2012-04-16T20:39:25.353

Reputation: 8 378

This is not always the case. Excel has sometimes munged my data even with a leading apostrophe. – Cerin – 2015-05-11T20:50:31.140

3Cerin, a fair point-never underestimate Excel (or Microsoft's) ability to do something completely unexplainable or repeatable. However, the apostrophe trick generally works as advertised. – dav – 2015-05-11T23:07:36.250

1can you do this in bulk? I have data with 60000 cells that I want to convert to text. – vaibhavcool20 – 2018-04-08T15:44:46.623

Or just choose to format as text in right-click, Format Cells menu ;) – Shayan – 2019-05-08T14:08:42.387

13

I found that in Office 2010, if you format the column first, and then paste in the data, it will show the large numbers correctly.

M Akin

Posted 2012-04-16T20:39:25.353

Reputation: 131

1This works in Excel 2016/Office 365. I selected all cells, formatted them to Text and then pasted my copied data and it did not show up with the annoying scientific notation. Thanks! – frezq – 2017-06-12T08:18:42.350

This what also worked for me in Google Sheets... "Format > Number > 0" prior to pasting in vals and didn't convert to scientific notation while also NOT losing end values (rounding down of vals), which was happening too often. – twknab – 2019-09-30T18:48:24.413

That is probably because it is stored as a string. What happens if you make another cell be, say, the cell's content multiplied by 2? – Peter Mortensen – 2013-01-11T12:15:22.337

12

Try this... this works for me, Excel 2013.

=""&a1

where a1 holds the numeric value. After, copy the column and paste to original column.

Rok

Posted 2012-04-16T20:39:25.353

Reputation: 153

This works in Excel 2010 as well. – Paul G – 2013-07-10T14:12:28.810

2As a side node: ="1240800388917" does the same – nixda – 2013-07-25T20:41:33.250

6

I'm aware of the age of the question, but this is the one I've landed after google search and which did not answered my question (why formatting as text doesn't work and why number is cut down to 15 digits after format to text).

Short answer is: you can't work on your number the way you like AFTER you entered the numeric value and tapped Enter. The moment you do that the number will be truncated to 15 digits and presented in as exponential.

This is not a bug, it's a feature.

Anything you do after that will be using the truncated value, so no formatting trick will help. However, you can use the Text to columns option to convert exponential notation to text (Click on column header, click Text to data, then Delimited, Next, untick all delimiter boxes, Select Text in Column data format and then Finish) to have the values converted to text and immediately displayed as 15 digit number. But, it will be only 15 digits, so if you had longer number, rest is lost.

In order to have the number in the spreadsheet exactly the way you typed it in you have to store it as text. So you have to precede it with apostrophe or format cells as text before typing/copying values into it. If it "sometimes doesn't work", then, sorry, you either do something wrong or you have some sort of autocorrect on (if you use apostrophe and large number >15 digits Excel treats it as a wrong value and flags cell with warning message, so this remark is not personal nor critique).

Other way to do it in bulk numbers is to import values from text file. I dare say it's the only way for most situations. And be sure to import the file, not just open it, as Excel treats csv type like it's native format and trims large numbers to 15 digits as a matter of course.

Now, to the last issue. If you enter large numerical value in Excel cell formatted as text it will still be displayed in scientific notation as long as the cell is not wide enough. It's annoying, but side effect of some Excel internal algorithms. Just make the cell wider and you'll see full value every time.

AcePL

Posted 2012-04-16T20:39:25.353

Reputation: 1 571

A side note: Text to columns is in the ribbon menu under Data. – Culip – 2020-01-30T16:17:20.637

I'd say it's a bug considering the behavior is maddening and makes no sense to a human. I have NEVER wanted a long integer converted to e-notation. – pbreitenbach – 2020-02-27T23:05:54.783

5

You can format cells as Custom > #

This can be applied after you paste the data into the column, but you must do it before you save the spreadsheet.

I work a lot with barcodes (UPC's) and excel will format them as scientific notation by default. Drives me nuts! Why this isn't an option I'll never know.

Graham

Posted 2012-04-16T20:39:25.353

Reputation: 51

That doesn't transform the numbers to text though, which can cause problems later on. But well... – Joris Meys – 2016-01-11T09:44:12.447

3

Excel 2010: This works one column at a time and not at all for a row. Select the column or subset of a column, from the Data tab select "Text to Columns", and jump right to "Finish." No more scientific notation.

I agree with the many Excel users, it's criminal that there is no option to prevent scientific notation!

gsoClarke

Posted 2012-04-16T20:39:25.353

Reputation: 31

1In my test on Excel 2007, I had to click Next > twice, then select “Text” and click Finish.  You can apply this to rows by transposing, converting, and transposing back. – Scott – 2013-08-14T23:59:50.017

1

Excel is frustrating for CSV/bulk data work like this. Work with LibreOffice if possible, it doesn't do this, that is, if you open the same sheet (.xlsx) in Libreoffice, the large 'numbers' which are actually strings are not displayed in scientific notation (which is an absurd decision by Excel). LibreOffice's file fidelity is great: open the same .xlsx in Excel again, and the scientific notation instantly "works" just like usual.

Tim Richardson

Posted 2012-04-16T20:39:25.353

Reputation: 151

1

In Excel 2013, the same thing happened to me and I just went to Format Cells -> Number then made sure the decimal place is set to "0".

Christopher Chipps

Posted 2012-04-16T20:39:25.353

Reputation: 752

1similar to Anonymous answer above but selecting "Number" somehow makes more sense than selecting "custom".. plus it's higher on the list. anyway, it does the same thing but I like this better – billynoah – 2016-02-09T01:55:39.150

0

Select all the cells — or, to make things easy — select the entire spreadsheet and click Format Cells, then Text.

Automatically, your whole spreadsheet will use text. You don't have to do it cell by cell.

Dima

Posted 2012-04-16T20:39:25.353

Reputation: 194

Alas, this doesn't work. The text will just be in scientific notation, that's the whole problem... – Joris Meys – 2016-01-11T09:44:45.943

0

  1. Copy/paste problem field into new sheet in column A

  2. Copy/paste Column A into text file

  3. Format Column B to text and paste text file into Column B

  4. In Column C:

    =IF(ISNUMBER(SEARCH("+",B1)),A1,"")
    
  5. Convert Column C into a number format with no decimals

  6. Copy/paste Column C into text file

  7. Format Column D into text and paste text file to Column D

  8. In Column E:

    =IF(IF(IF(B2=A2,A2,D2)=0,A2,IF(B2=A2,A2,D2))=0,"",IF(IF(B2=A2,A2,D2)=0,A2,IF(B2=A2,A2,D2)))
    
  9. Copy/paste Column E into notepad

  10. Delete data in problem field and format column to text

  11. Copy/paste data from text file to problem field

DataWizard

Posted 2012-04-16T20:39:25.353

Reputation: 1

0

This worked for me in Excel 2013, including copy-pasting the cells out to other programs. Filtering the data helped, especially for the edit steps.

  1. Select your desired cell(s).
  2. Apply the Number Format "Text". (Try Alt, H, N, then "Text".)

Then, for each of your desired cells:

  1. Enter edit mode. (Try F2.)
  2. Confirm your edit with either Enter (good for columns) or Tab (good for rows). Do not alter the contents.

Your number will appear normally, even at 100 digits. =)

skia.heliou

Posted 2012-04-16T20:39:25.353

Reputation: 2 185

Does not work for multiple cells (Excel 365) – Albin – 2019-04-27T08:58:02.063