Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Double quote delimiter script
Someone wrote this script for my project a few years ago. I hadn't needed it
up until now. I am not sure if someone here in the ng wrote it or a colleague at work. It should be adding a double quotation delimiter in every field in the excel or csv file up to the last occupied field. But I must be missing something because its not working for me. Some fields will be blank even with the delimiters but that shouldn't matter here. Would one of you be able to tell me what isn't right about the following script? Thanks in advance, MrBT Sub Macro1() ' ' Macro1 Macro ' Macro recorded 4/17/2005 by sbeattie ' ' 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can the SUBSTITUTE function replace a double quote? | Excel Worksheet Functions | |||
double axis, double problem (i hope only to me) | Charts and Charting in Excel | |||
Quote marks in Formulas passed from VB Script in Excel | Excel Worksheet Functions | |||
Exporting single or double quote delimited files | Excel Worksheet Functions | |||
how do I create comma and double quote delimited file | Excel Discussion (Misc queries) |