Hoppa till huvudinnehåll

Hur konverterar man kolumnlista till kommaseparerad lista i Excel?

Om du vill konvertera en kolumnlista med data till en lista åtskild med kommatecken eller andra separatorer och mata ut resultatet till en cell som visas nedan kan du få det gjort med CONCATENATE-funktionen eller genom att köra en VBA i Excel.


Konvertera kolumnlista till kommaseparerad lista med TEXTJOIN-funktionen

Excel TEXTJOIN-funktionen sammanfogar flera värden från en rad, kolumn eller ett cellområde med specifik avgränsare.

Observera att funktionen endast är tillgänglig i Excel för Office 365, Excel 2021 och Excel 2019.

För att konvertera kolumnlistan till kommaseparerad lista, välj en tom cell, till exempel cellen C1, och skriv den här formeln =TEXTJOIN(", ",TRUE,A1:A7) (A1: A7 är kolumnen du kommer att konvertera till kommatandad lista, "" anger hur du vill separera listan). Se skärmdumpen nedan:


Konvertera kolumnlista till kommaseparerad lista med CONCATENATE-funktionen

I Excel kan CONCATENATE-funktionen konvertera kolumnlistan till en lista i en cell åtskild av kommatecken. Gör så här:

1. Välj en tom cell intill listans första data, till exempel cellen C1, och skriv den här formeln = CONCATENATE (TRANSPOSE (A1: A7) & ",") (A1: A7 är kolumnen du kommer att konvertera till kommatandad lista, "" anger avgränsaren du vill separera listan). Se skärmdumpar nedan:

2. Markera TRANSPONERA (A1: A7) & "," i formeln och tryck på F9 nyckel.

3. Ta bort lockade hängslen {och } från formeln och tryck på ange nyckel.

Nu kan du se alla värden i kolumnlistan konverteras en lista i en cell och separeras med komma. Se skärmdump ovan.

Konvertera snabbt en kolumnlista till en kommaseparerad lista med Kutools för Excel

Kutools för Excel Kombinera kolumner eller rader utan att förlora data verktyget kan hjälpa Excel-användare att enkelt kombinera flera kolumner eller rader i en kolumn / rad utan att förlora data. Dessutom kan Excel-användare slå in de här kombinerade textsträngarna med transport eller hård retur.


Konvertera kolumnlista till kommaseparerad lista med VBA

Om CONCATENATE-funktionen är lite tråkig för dig kan du använda en VBA för att snabbt konvertera kolumnlistan till en lista i en cell.

1. Håll ALT knappen och tryck på F11 på tangentbordet för att öppna en Microsoft Visual Basic för applikation fönster.

2. Klicka Insert > Modulernaoch kopiera VBA till modulen.

VBA: Konvertera kolumnlista till kommaseparerad lista

Sub ChangeRange()
'Updateby20140310
Dim rng As Range
Dim InputRng As Range, OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
outStr = ""
For Each rng In InputRng
    If outStr = "" Then
        outStr = rng.Value
    Else
        outStr = outStr & "," & rng.Value
    End If
Next
OutRng.Value = outStr
End Sub

3. Klicka Körning knappen eller tryck på F5 att köra VBA.

4. En dialogruta visas på skärmen och du kan välja den kolumnlista du vill konvertera. Se skärmdump:

5. Klicka OK, då dyker en annan dialog upp för att du ska välja en cell. Se skärmdump:

6. Klicka OKoch alla värden i kolumnlistan har konverterats till en lista åtskild med komma i en cell.

Tips: I ovanstående VBA anger "," den separator du behöver, och du kan ändra den efter behov.


Konvertera kolumnlista till kommaseparerad lista med Kutools för Excel

Du kan också använda Kutools för Excel Kombinera verktyg för att kombinera en kolumnlista och enkelt separera varje värde med komma.

Kutools för Excel - Superladda Excel med över 300 viktiga verktyg. Njut av en fullfjädrad 30-dagars GRATIS provperiod utan behov av kreditkort! Hämta den nu

1. Välj den kolumnlista som du ska konvertera till en kommaseparerad lista och klicka på Kutools > Slå ihop och dela> Kombinera rader, kolumner eller celler utan att förlora data.

2. I den öppna dialogrutan Kombinera kolumner eller rader måste du:
(1) Kontrollera Kombinera rader alternativet i Att kombinera valda celler enligt följande alternativ sektion;
(2) I Ange en separator avsnitt, kolla på Annan avskiljare och skriv kommatecken , i följande ruta;

3. Klicka på Ok knapp.

Nu ser du alla värden i den angivna kolumnlistan kombineras i en cell och konverteras till en kommaseparerad lista.

Kutools för Excel - Superladda Excel med över 300 viktiga verktyg. Njut av en fullfjädrad 30-dagars GRATIS provperiod utan behov av kreditkort! Hämta den nu


Demo: konvertera kolumnlista till kommaseparerad lista i Excel


Kutools för Excel: Över 300 praktiska verktyg till hands! Börja din 30-dagars gratis provperiod utan funktionsbegränsningar idag. Ladda ner nu!

Omvänd sammanfoga och konvertera en cell (en kommatandad lista) till en rad / kolumnlista i Excel

Normalt kan Excel-användare använda Text till kolumner funktion för att dela en cell till flera kolumner, men det finns ingen direkt metod för att konvertera en cell till flera rader. Men Kutools för Excel Dela celler verktyget kan hjälpa dig att enkelt få det gjort enligt nedanstående skärmdump.



Relativa artiklar:

Comments (34)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
Hi Eric,
Thanks for you feedback. Since the TEXTJOIN is a rather new function, it was not there when we wrote the instruction. I will include the function in the article. Thanks so much.
Amanda
This comment was minimized by the moderator on the site
Major time saving technique - thank you!
This comment was minimized by the moderator on the site
Doesn't work, too many arguments in function.
This comment was minimized by the moderator on the site
This was a life saver! Thanks
This comment was minimized by the moderator on the site
Can someone help in converting a cell wish Value

Football, Baseball, Cricket

into


1. Football, 2. Baseball, 3. Cricket
This comment was minimized by the moderator on the site
Hi ADMINDIVISION,
You can use the Text to Columns (Excel built-in feature) or Split Cells (of Kutools for Excel) to split the cell to three columns or rows, and then apply the Insert Bullets or Numbering feature of Kutools for Excel to quickly insert numbering for the new cells/columns/rows.

Btw, there is an article introducing several solutions to inserting bullets or numberings into cells:https://www.extendoffice.com/documents/excel/950-excel-apply-bullets-numbering.html
This comment was minimized by the moderator on the site
I need to get my numbers to look like this ('1234567', '1234567') instead of ("1234567", "1234567") - any ideas!?
This comment was minimized by the moderator on the site
=SUBSTITUTE(value,CHAR(34),CHAR(39))
This comment was minimized by the moderator on the site
Hi,
There are no double quotas or quotas in the conversation results with any one of methods in this article.
This comment was minimized by the moderator on the site
Absolutely magic!Thanks!
This comment was minimized by the moderator on the site
Used This one: "Convert column list to comma separated list with VBA", worked perfect for converting rows (1000+) of email addresses into a combined list that my email client works well with. Just changed the "," to "; " and it was good to go. Thanks!
This comment was minimized by the moderator on the site
I would like to know how did you manage to copy the comma separated values from Excel Spreadsheet to Outlook/other main client. The reason being whenever I copy, the only formula gets copied but not the comma separated values. Please support.
This comment was minimized by the moderator on the site
Hi, Ravindran, you shold copy the formula result and the paste it into a cell as value firstly, then copy the pased value to other devices.
https://www.extendoffice.com/images/stories/comments/sun-comment/paste%20as%20value.png?1697765930000
This comment was minimized by the moderator on the site
Hi All, So for a few columns this formula is great, but if you were trying to figure this out on more cloumns more than 100. putting "&" is a waste of time. For me i needed sepration through "," (comma). for that, all you need to do is to separate the file in CSV, Open it on a Notepad, Copy and paste in in Word, then Copy again from Word and paste it on Excel. Hope you like to the suggested, Have a great day. Thank you, Mayank Bhargava
This comment was minimized by the moderator on the site
The VBA helped out so much! I am experiencing an issue if you try to close the pop up box or cancel it, it will show that the vba needs debugged. This also happens if the value is blank. Any ideas on how to fix this? Thanks!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations