ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   exporting data (https://www.excelbanter.com/excel-programming/383043-exporting-data.html)

Ernst Guckel[_4_]

exporting data
 
Hello,

I am trying to export data to a text file... The problem is that the data
needs to be loaded as a string to preserve leading zeros but when i "Write"
the data to the file it puts "s in the data file...

Here is some code:
Dim c As Range
Dim intTemp As Variant
Dim strFileName As String
strFileName = "C:\FoodCost.Dat"
Open strFileName For Output As #1 ' Open file for output.

For Each c In Range("ItemRange")

intTemp = c.Cells(1, 8).Value
If c.Cells(1, 8).Value = "" Then GoTo NextItem

Write #1, CDec(intTemp)


NextItem:
Next
Close #1 ' Close file.

Here is an exerpt of the file:

"0000000367"
"0010000408"
"0030000588"
"0040000670"

the #s have to be 10 digits with leading 0s... any help would be great...

Ernst.



All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com