I have a text file I open up in excel. One of the columns has numbers
with leading zeros. I change the format to text and I save it as a csv
file. Then when I import the file into another program the zeros are
gone. I also have some numbers like(65110231147009) and when I import
the file into another program, they end up like (6.51E+13) which turns
the number into (65100000000000). I also reopened the spreadsheet after
saving it and they are not correct. Is this because I am saving the
spreadsheet as a csv? If so how can I keep the data correct? I have to
use csv or xml to import the data into another program. I am using
excel 97.




Create your CSV file using the old method

Sub CreateCSV()
Dim strLine As String
Dim FileNum As Integer
Dim cl As Range
Dim i As Byte
FileNum = FreeFile
Open "C:\Yourpath\MyCsvFile.csv" For Output As #FileNum

For Each cl In Range("A1", Range("A1").End(xlDown))
i = 1
strLine = cl.Value
Do While IsEmpty(cl.Offset(, i)) = False
strLine = strLine & ", " & cl.Offset(, i) 'format your cell value here
as applicable
i = i + 1
Print #FileNum, strLine
Next cl
Close #FileNum
MsgBox "C:\Yourpath\MyCsvFile.csv created !", vbInformation, "Export done"
End Sub


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