Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Comma Delimited-need comma at beginnng & end

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Comma Delimited-need comma at beginnng & end

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Comma Delimited-need comma at beginnng & end

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
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
Comma Delimited Numbers Spannerman Excel Discussion (Misc queries) 3 April 3rd 07 08:19 AM
Creating CSV Comma Delimited File Connie Excel Discussion (Misc queries) 1 October 19th 06 04:27 PM
Importing Comma delimited file Patsy Rogge Excel Discussion (Misc queries) 2 April 20th 06 02:50 PM
Comma delimited question Carol Excel Discussion (Misc queries) 2 January 15th 05 11:32 AM
HELP - I need to change space delimited to comma? Mayer Excel Discussion (Misc queries) 1 December 18th 04 06:21 PM


All times are GMT +1. The time now is 10:11 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"