CoolDudeeh
IS-IT--Management
Ok ..... here is my situation.
I have an excel spreadsheet with data in it from A1-X700
I found the below macro to put out the cells with " around the data in each cell.
The below macro works great ...... but I would like to modify it not to put " around data in certain columns.
For example I want "around" each cells info except say column D and N.
Can anyone help me?
Public Sub OutputQuotedCSV()
Const QSTR As String = """"
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
nFileNum = FreeFile
Open "file.txt" For Output As #nFileNum
For Each myRecord In Range("A2:A723")
With myRecord
For Each myField In Range(.Cells(1), _
Cells(.Row, 256).End(xlToLeft))
sOut = sOut & " " & QSTR & _
Replace(myField.Text, QSTR, QSTR & QSTR) & QSTR
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
End Sub
I have an excel spreadsheet with data in it from A1-X700
I found the below macro to put out the cells with " around the data in each cell.
The below macro works great ...... but I would like to modify it not to put " around data in certain columns.
For example I want "around" each cells info except say column D and N.
Can anyone help me?
Public Sub OutputQuotedCSV()
Const QSTR As String = """"
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
nFileNum = FreeFile
Open "file.txt" For Output As #nFileNum
For Each myRecord In Range("A2:A723")
With myRecord
For Each myField In Range(.Cells(1), _
Cells(.Row, 256).End(xlToLeft))
sOut = sOut & " " & QSTR & _
Replace(myField.Text, QSTR, QSTR & QSTR) & QSTR
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
End Sub