![]() |
Automated " delimiter adder?
I found the following in my script archives. I thought it was for adding a "
delimiter to a text file but I cannot seem to remember how to make this work. I thought I would ask some of you to help me out. Thank you in advance. Mr BT 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 "File1.txt" For Output As #nFileNum For Each myRecord In Range("A1:A" & _ Range("A" & Rows.Count).End(xlUp).Row) 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 |
Automated " delimiter adder?
See
http://www.mvps.org/dmcritchie/excel/getstarted.htm In article <siE6i.231586$6m4.18530@pd7urf1no, "Mr BT" wrote: I found the following in my script archives. I thought it was for adding a " delimiter to a text file but I cannot seem to remember how to make this work. I thought I would ask some of you to help me out. Thank you in advance. Mr BT 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 "File1.txt" For Output As #nFileNum For Each myRecord In Range("A1:A" & _ Range("A" & Rows.Count).End(xlUp).Row) 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 |
All times are GMT +1. The time now is 02:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com