Assuming your data starts in A1 I would put the following in column B:
B1:
=A1
B2:
=B1&","&A2
You can then paste column B2 down the whole column. The last cell in column B should now be a comma separated list of column A.
Answer from Sux2Lose on Stack Exchangecsv - Converting Excel values into double quotation with commas between them - Stack Overflow
Converting multiple columns/rows of text into comma seperated rows of text
Surround values with single quote
vba - How to add single quote and comma to all values in a column? - Stack Overflow
Can I add quotes?
Can I remove duplicates?
Which separator should I use?
Videos
Assuming your data starts in A1 I would put the following in column B:
B1:
=A1
B2:
=B1&","&A2
You can then paste column B2 down the whole column. The last cell in column B should now be a comma separated list of column A.
- Copy the column in Excel
- Open Word
- "Paste special" as text only
- Select the data in Word (the one that you need to convert to text separated with
,), press Ctrl-H (Find & replace) - In "Find what" box type
^p - In "Replace with" box type
, - Select "Replace all"
I have an excel that has over 3000+ rows of text in different columns that i need to convert into comma seperated text for csv.
Example:
Column1 | Column2| Column3
Name | surname | phonenumber
Name1 | surname1 | phonenumber1
I need to get all of these converted into the following lines of text:
Name,surname,phonenumber
Name1,surname1,phonenumber1
Bonus points if i can convert them to a text format of:
,"XXX","Name","surname","phonenumber","YYY","ZZZ"
,"XXX","Name1","surname1","phonenumber1","YYY","ZZZ"
The xxx, yyy and zzz being static information that is same for every row.
I can do it row by row with =TEXTJOIN() but i cant add the static information and doing it one row at a time seems tedious.
Help pls :>
Your original UDF was close. You just need to join with ',' rather than , and then place ' at the start and end of your output string
Public Function MergeME(r As Range) As String
MergeME = "'" & Join(Application.Transpose(r.Value), "','") & "'"
End Function
Output string as required:
'server1.abc.com','server2.abc.com','server3'
With data in A1 through A3, in B1 enter:
="'"
(this is a single quote encased in double quotes)
Then in B2:
=B1 & A1 & B1 & "," & B1 & A2 & B1 & "," & B1 & A3 & B1
