Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can the SUBSTITUTE function replace a double quote? Florence Excel Worksheet Functions 6 April 3rd 23 02:26 PM
double axis, double problem (i hope only to me) kitcho Charts and Charting in Excel 1 December 30th 06 01:52 AM
Quote marks in Formulas passed from VB Script in Excel Graysailor Excel Worksheet Functions 2 September 26th 06 07:29 PM
Exporting single or double quote delimited files Greegan Excel Worksheet Functions 2 April 18th 05 05:25 AM
how do I create comma and double quote delimited file mikeb Excel Discussion (Misc queries) 1 November 29th 04 11:01 PM


All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"