RobbieC
Active Member
- Joined
- Dec 14, 2016
- Messages
- 376
- Office Version
- 2010
- Platform
- Windows
Hi there, I have been using this script successfully to export data from a sheet to csv (.txt):
However, this script inserts double quotes around each "item" - I need to export the file without double quotes... Is there any way to adapt my above script to do this or will I have to look for a new solution?
If you can point me in the right direction, I'd be most grateful
Thanks
Code:
Sub CSVExport()
Dim var1 As String
Dim var2 As String
Dim var3 As String
Dim var4 As String
'Find the last row that contains data
With Worksheets("Sheet1")
lLastRow = .Cells(.Rows.Count, "A").End(xlUp).row
End With
'Setting the name and the path of text file based on workbook path
sFName = ThisWorkbook.Path & "csvoutput.txt"
'Get an unused file number
intFNumber = FreeFile
'Create a new file (or overwrite an existing one)
Open sFName For Output As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=intFNumber]#intFNumber[/URL]
For lCounter = 1 To lLastRow
'Read specific data from the worksheet
With Worksheets("Sheet1")
var1 = .Cells(lCounter, 1)
var2 = .Cells(lCounter, 2)
var3 = .Cells(lCounter, 3)
var4 = .Cells(lCounter, 4)
End With
'Write selected data to text file
Write [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=intFNumber]#intFNumber[/URL] , var1, var2, var3, var4
'Continue looping until the last row
Next lCounter
'Close the text file
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=intFNumber]#intFNumber[/URL]
End Sub
However, this script inserts double quotes around each "item" - I need to export the file without double quotes... Is there any way to adapt my above script to do this or will I have to look for a new solution?
If you can point me in the right direction, I'd be most grateful
Thanks