Convert a column into a comma separated list (2025)

14 Answers

Reset to default

173

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.

Improve this answer

answered Feb 2, 2011 at 16:37

Sux2LoseSux2Lose

3,36722 gold badges1717 silver badges1717 bronze badges

2

  • 10

    This is great for a limited number of rows, but (depending on available memory?) the process will cut short if you're concatenating beyond a couple thousand rows, leaving your output value incomplete. Be careful.

    samthebrand

    Commented Sep 18, 2014 at 21:47

  • Using Excel 2013 on a powerful Windows 10 Pro computer, this failed after only 30-35 lines. I needed well over 200. Solution by Michael Joseph worked perfectly.

    Trialsman

    Commented Jun 5, 2019 at 19:30

Add a comment |

112

  • 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"

Improve this answer

edited Sep 22, 2014 at 22:07

Lee Taylor

1,50411 gold badge1717 silver badges2222 bronze badges

answered Jun 5, 2012 at 5:24

Michael JosephMichael Joseph

1,12111 gold badge77 silver badges22 bronze badges

4

  • +1 Same as "official" solution here by Microsoft: support.microsoft.com/kb/819964

    Neo

    Commented Dec 30, 2013 at 15:51

  • 1

    very cute solution... :-)

    Saravanan

    Commented Feb 11, 2014 at 6:35

  • 1

    As a last step -> Remove the , after the last number. :-)

    Gautham M

    Commented May 30, 2021 at 15:33

  • Even after more than a decade, this is still the only reasonable working solution in converting multiple values to a single text value when working with a local Excel file.

    Codingwiz

    Commented May 16, 2023 at 14:24

Add a comment |

101

If you have Office 365 Excel then you can use TEXTJOIN():

=TEXTJOIN(",",TRUE,A:A)

Convert a column into a comma separated list (4)

Improve this answer

answered Jan 25, 2017 at 18:05

Scott CranerScott Craner

23.8k44 gold badges2424 silver badges2626 bronze badges

8

  • 3

    As Scott points out, important caveat is Excel 365 only. Function does not exist in Excel 2016.

    WhyGeeEx

    Commented Sep 30, 2020 at 20:07

  • 2

    If you need a quote separated list 'a','b','c', try ="'" & TEXTJOIN("','",TRUE,A:A) & "'"

    Stevoisiak

    Commented Oct 28, 2020 at 19:31

  • The most elegant solution!

    Paul-Sebastian Manole

    Commented Mar 2, 2022 at 11:22

  • ✅ Accepted answer. If you have an input array: =REDUCE(,F7:F10, LAMBDA(a,b,CONCAT(a,", ",b)))

    Renato Heeb

    Commented Apr 6, 2023 at 10:46

  • 1

    Nice answer, unless you have a big list. I think it's limited by the max characters a cell can contain: 32,767 characters

    cs_pupil

    Commented May 9, 2023 at 18:50

| Show 3 more comments

26

I actually just created a module in VBA which does all of the work. It takes my ranged list and creates a comma-delimited string which is output into the cell of my choice:

Function csvRange(myRange As Range) Dim csvRangeOutput Dim entry as variant For Each entry In myRange If Not IsEmpty(entry.Value) Then csvRangeOutput = csvRangeOutput & entry.Value & "," End If Next csvRange = Left(csvRangeOutput, Len(csvRangeOutput) - 1)End Function

So then in my cell, I just put =csvRange(A:A) and it gives me the comma-delimited list.

Improve this answer

edited Oct 28, 2020 at 19:35

Stevoisiak

15.4k4444 gold badges112112 silver badges176176 bronze badges

answered Feb 3, 2011 at 14:10

muncherellimuncherelli

2,53944 gold badges2626 silver badges3131 bronze badges

2

  • 2

    Ah.. pretty close to my answer, but I like your implementation.

    mpeterson

    Commented Feb 3, 2011 at 14:27

  • I like it. You may just want to check to see if Len(csvRangeOutput) is 0 before returning csvRange. If 0, you'll have a run time error.

    WhyGeeEx

    Commented Sep 30, 2020 at 20:42

Add a comment |

12

An alternative approach would be to paste the Excel column into this in-browser tool:

convert.town/column-to-comma-separated-list

It converts a column of text to a comma separated list.

As the user is copying and pasting to another program anyway, this may be just as easy for them.

Improve this answer

edited Apr 22, 2015 at 20:56

answered Apr 22, 2015 at 20:46

sunsetsunset

31922 silver badges33 bronze badges

Add a comment |

7

Use vi, or vim to simply place a comma at the end of each line:

%s/$/,/

To explain this command:

  • % means do the action (i.e., find and replace) to all lines
  • s indicates substitution
  • / separates the arguments (i.e., s/find/replace/options)
  • $ represents the end of a line
  • , is the replacement text in this case

Improve this answer

edited Sep 27, 2013 at 9:18

Jeromy Anglim

74111 gold badge1010 silver badges1919 bronze badges

answered Feb 6, 2011 at 22:53

BreathworkBreathwork

7911 bronze badge

2

  • Disagree with comments because of context. Someone with a superuser account who posts here is often the type to use vim.

    uniquegeek

    Commented Mar 1, 2016 at 20:25

  • I but use ViM and think the basic idea is useful. I ended up solving the problem by using the idea and a simple text editor.

    Nigini

    Commented Dec 16, 2016 at 17:16

Add a comment |

7

You could do something like this. If you aren't talking about a huge spreadsheet this would perform 'ok'...

  • Alt-F11, Create a macro to create the list (see code below)
  • Assign it to shortcut or toolbar button
  • User pastes their column of numbers into column A, presses the button, and their list goes into cell B1.

Here is the VBA macro code:

Sub generatecsv() Dim i As IntegerDim s As Stringi = 1Do Until Cells(i, 1).Value = "" If (s = "") Then s = Cells(i, 1).Value Else s = s & "," & Cells(i, 1).Value End If i = i + 1 Loop Cells(1, 2).Value = sEnd Sub

Be sure to set the format of cell B1 to 'text' or you'll get a messed up number. I'm sure you can do this in VBA as well but I'm not sure how at the moment, and need to get back to work. ;)

Improve this answer

edited Oct 28, 2020 at 19:37

Stevoisiak

15.4k4444 gold badges112112 silver badges176176 bronze badges

answered Feb 2, 2011 at 19:12

mpetersonmpeterson

55122 silver badges44 bronze badges

Add a comment |

2

You could use How-To Geek's guide on turning a row into a column and simply reverse it. Then export the data as a csv (comma-deliminated format), and you have your plaintext comma-seperated list! You can copy from notepad and put it back into excel if you want. Also, if the you want a space after the comma, you could do a search & replace feature, replacing "," with ", ". Hope that helps!

Improve this answer

answered Feb 2, 2011 at 16:12

DuallDuall

71755 silver badges1919 bronze badges

1

  • Exporting to CSV is beyond what this user can do. I need it to be point and click within excel.

    muncherelli

    Commented Feb 2, 2011 at 16:15

Add a comment |

2

muncherelli, I liked your answer, and I tweaked it :). Just a minor thing, there are times I pull data from a sheet and use it to query a database. I added an optional "textQualify" parameter that helps create a comma seperated list usable in a query.

Function csvRange(myRange As Range, Optional textQualify As String) 'e.g. csvRange(A:A) or csvRange(A1:A2,"'") etc in a cell to hold the string Dim csvRangeOutput For Each entry In myRange If Not IsEmpty(entry.Value) Then csvRangeOutput = csvRangeOutput & textQualify & entry.Value & textQualify & "," End If Next csvRange = Left(csvRangeOutput, Len(csvRangeOutput) - 1)End Function

Improve this answer

edited Oct 28, 2020 at 19:37

Stevoisiak

15.4k4444 gold badges112112 silver badges176176 bronze badges

answered Apr 8, 2011 at 15:54

mitchmitch

2111 bronze badge

Add a comment |

1

Sux2Lose's answer is my preferred method, but it doesn't work if you're dealing with more than a couple thousand rows, and may break for even fewer rows if your computer doesn't have much available memory.

Best practice in this case is probably to copy the column, create a new workbook, past special in A1 of the new workbook and Transpose so that the column is now a row. Then save the workbook as a .csv. Your csv is now basically a plain-text comma separated list that you can open in a text editor.

Note: Remember to transpose the column into a row before saving as csv. Otherwise Excel won't know to stick commas between the values.

Improve this answer

edited Mar 20, 2017 at 10:17

CommunityBot

1

answered Oct 6, 2014 at 22:56

samthebrandsamthebrand

34011 gold badge55 silver badges2222 bronze badges

Add a comment |

1

I improved the generatecsv() sub to handle an excel sheet that contains multiple lists with blank lines separating both the titles of each list and the lists from their titles. example

list title 1item 1item 2list title 2item 1item 2

and combines them of course into multiple rows, 1 per list.

reason, I had a client send me multiple keywords in list format for their website based on subject matter, needed a way to get these keywords into the webpages easily. So modified the routine and came up with the following, also I changed the variable names to meaningful names:

Sub generatecsv() Dim dataRow As Integer Dim listRow As Integer Dim data As String dataRow = 1: Rem the row that it is being read from column A otherwise known as 1 in vb script listRow = 1: Rem the row in column B that is getting written Do Until Cells(dataRow, 1).Value = "" And Cells(dataRow + 1, 1).Value = "" If (data = "") Then data = Cells(dataRow, 1).Value Else If Cells(dataRow, 1).Value <> "" Then data = data & "," & Cells(dataRow, 1).Value Else Cells(listRow, 2).Value = data data = "" listRow = listRow + 1 End If End If dataRow = dataRow + 1 Loop Cells(listRow, 2).Value = dataEnd Sub

Improve this answer

edited Oct 28, 2020 at 19:38

Stevoisiak

15.4k4444 gold badges112112 silver badges176176 bronze badges

answered Sep 28, 2011 at 17:23

roger lambroger lamb

1111 bronze badge

Add a comment |

I did it this way

Removed all the unwanted columns and data, then saved as .csv file, then replaced the extra commas and new line using Visual Studio Code editor. Hola

Improve this answer

answered Nov 29, 2019 at 7:33

Arun Prasad E SArun Prasad E S

11133 bronze badges

Add a comment |

-1

One of the easiest ways is to use zamazin.co web app for these kind of comma separating tasks. Just fill in the column data and hit the convert button to make a comma separated list. You can even use some other settings to improve the desired output.

http://zamazin.co/comma-separator-tool

Convert a column into a comma separated list (21)

Improve this answer

edited Nov 22, 2016 at 8:28

answered Nov 2, 2016 at 12:45

HakanHakan

48111 gold badge44 silver badges66 bronze badges

1

  • This is now at delim.co

    Phil

    Commented Dec 10, 2018 at 19:53

Add a comment |

-3

Use =CONCATENATE(A1;",";A2;",";A3;",";A4;",";A5) on the cell that you want to display the result.

Improve this answer

edited Feb 3, 2011 at 11:39

answered Feb 2, 2011 at 16:32

JohnnyJohnny

89411 gold badge88 silver badges1919 bronze badges

1

  • 5

    This is an unscalable manual solution.

    Daniel Hári

    Commented Apr 7, 2016 at 9:49

Add a comment |

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

  • microsoft-excel

See similar questions with these tags.

Convert a column into a comma separated list (2025)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 6067

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.