Linens
Linens

Reputation: 7942

saving csv from excel loses decimal point precision

If I create a simple .csv file containing something like this:

01/22/2013,3.14159265358979323846264338

and proceed to open it up in excel, the cell will show a rounded number i.e. 3.141592654 and the formula bar will show the whole value. However if I make some changes and save the csv file, or just save the original file as a different csv file, the file will only contain the rounded number 3.141592654, causing me to lose some decimal point precision.

I am writing these files out via a vba macro. I have tried :

ActiveWindow.DisplayFormulas=True

before the save command, and it works except it changes my date into a numeric format and I have not figured out a way to apply this format to only a range of cells. Is there some simple way to keep my numeric precision?

Upvotes: 4

Views: 13786

Answers (1)

Vinny Roe
Vinny Roe

Reputation: 901

If you know which cells are going to be affected, try something like

Range("MYNUMBERS").NumberFormat = "#0.000000000000000"

?

Upvotes: 4

Related Questions