ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Substitute comma in csv file (https://www.excelbanter.com/excel-programming/271210-re-substitute-comma-csv-file.html)

jlewis

Substitute comma in csv file
 
Another way is to create a string that contatenates all
the necessary data and puts comma's (using string
concatenation). I just put the new, concatenated string
in a new cell (maybe on a new tab) for data output.
Concatenate the comma to the existing string data as:

=B2&","&C2&"," etc.,

ugly but it works

-----Original Message-----
One way:

Public Sub MySV()
Const DELIMITER As String = "^"
Dim cell As Range
Dim myRow As Range
Dim sOut As String
Open "Test.txt" For Output As #1
For Each myRow In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With myRow
For Each cell In Range(.Cells, _
Cells(.Row, Columns.Count).End

(xlToLeft))
sOut = sOut & DELIMITER &

cell.Text
Next cell
Print #1, Mid(sOut, 2)
sOut = Empty
End With
Next myRow
Close #1
End Sub

substitute your favorite character in DELIMITER as

desired...

Note: This routine assumes you have data in column A of

your last
row.

In article ,
"ajs" wrote:

I want to produce a .txt or .csv file from Excel that
separates each cell with a character of MY choice. I

can
successfully create tab and comma delimited files, but

not
one using a single delimiter of my choice. Any ideas
gratefully received.

.



All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com