Properly Saving a .CSV File With an 11 Digit Numeric Field

S

Sheldon Potolsky

My VBA code saves a spreadsheet as a .csv (... FileFormat:=xlCSV).
The problem? The one numeric field, an eleven digit number, converts
to exponential form, which I don't want.
Any way to do what I am trying to accomplish?

Thanks, Sheldon
 
M

Mike S

My VBA code saves a spreadsheet as a .csv (... FileFormat:=xlCSV).
The problem? The one numeric field, an eleven digit number, converts
to exponential form, which I don't want.
Any way to do what I am trying to accomplish?
Thanks, Sheldon

I don't know if this will help or not, using Excel 2000 when I format
the cells in a column containing numbers with 11 decimal points as text
and save the sheet as csv, the numbers are saved with all of the decimal
points, I can see that by opening the csv file with a text editor. But
when I open the csv file in Excel, only 9 of the decimal places are
displayed. I couldn't find a setting to restore displaying all 11 of
them anywhere, although one probably exists.

http://www.eggheadcafe.com/software/aspnet/33796987/preserving-trailing-zeros-from-csv-file.aspx
 
N

nz rb

here is a snippet of my code, from research i did on this problem. basically, if excel sees/displays it in a certain way (as in it drops seconds in the date time, for instance), thats how it converts it. thus, you have to custom-set the format of the cell/column

'Have to update dateformat in column H because conversion to csv will drop seconds
'if excel doesnt see complete format

'find last row to apply number format to
Dim iLastRow
iLastRow = Mid(Range("H65536").End(xlUp).Address(0, 0), 2)

Range("H6").Select
Range(Selection, Selection.End(xlDown)).Select
Range("H6:H" & iLastRow).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.NumberFormat = "m/d/yyyy hh:mm:ss"



-hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top