PC Review


Reply
Thread Tools Rate Thread

Comma Delimited-need comma at beginnng & end

 
 
Tattoo
Guest
Posts: n/a
 
      11th Dec 2007
How do you do a comma delimited file that has a comma in the first cell and
the last cell? Whenever I put a comma in the first and last column, it puts
quotation marks around the comma.
--
Tattoo
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      11th Dec 2007
Here is code that I have used before (slighly modified) that a I have posted
a number of times before. It always gives great results. Modify the 2nd and
3rd lines as required.


Sub WriteCSV()
Const MyPath = "C:\temp\"
Const WriteFileName = "text.csv"

Const Delimiter = ","
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fswrite = CreateObject("Scripting.FileSystemObject")
'open files
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

For RowCount = 1 To LastRow
LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Column
For ColCount = 1 To LastCol
If ColCount = 1 Then
OutputLine = "," & Cells(RowCount, ColCount)
Else
OutputLine = OutputLine & Delimiter & Cells(RowCount, ColCount)
End If
Next ColCount
OutputLine = OutputLine & ","
tswrite.writeline OutputLine
Next RowCount

tswrite.Close

Exit Sub
End Sub


"Tattoo" wrote:

> How do you do a comma delimited file that has a comma in the first cell and
> the last cell? Whenever I put a comma in the first and last column, it puts
> quotation marks around the comma.
> --
> Tattoo

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Dec 2007
How about putting something else in that first column?

I like to use a formula that makes the cell look blank:
=""



Tattoo wrote:
>
> How do you do a comma delimited file that has a comma in the first cell and
> the last cell? Whenever I put a comma in the first and last column, it puts
> quotation marks around the comma.
> --
> Tattoo


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial comma delimited text - Import to XL evry 8th comma nuRow Billp Microsoft Excel Programming 30 23rd Jun 2009 11:51 PM
Using comma inside the comma delimited text in Data Validation/Sou LasseH Microsoft Excel Programming 5 14th Dec 2007 04:09 AM
delimited, but Non-Comma Delimited file, for input. Ross.prillaman@HCAhealthcare.com Microsoft Access External Data 1 15th Aug 2005 05:55 PM
difference between comma delimited and tabbed delimited? Jones Microsoft Outlook Discussion 3 1st Jun 2005 08:23 AM
Comma Delimited ABASSANETTI Microsoft Excel Misc 2 9th Jul 2004 09:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:42 PM.