Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
gh gh is offline
external usenet poster
 
Posts: 6
Default LeadingZeros\CSV

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.

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default LeadingZeros\CSV

Hi,

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
Loop
Print #FileNum, strLine
Next cl
Close #FileNum
MsgBox "C:\Yourpath\MyCsvFile.csv created !", vbInformation, "Export done"
End Sub

Regards
Jean-Yves

"gh" wrote in message
...
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.

TIA



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"