跳到主要內容

如何在Excel中將列列表轉換為逗號分隔的列表?

如果要將列數據列表轉換為用逗號或其他分隔符分隔的列表,並將結果輸出到如下所示的單元格中,則可以通過CONCATENATE函數或在Excel中運行VBA來完成。


使用 TEXTJOIN 函數將列列表轉換為逗號分隔列表

Excel TEXTJOIN函數使用特定的分隔符將行,列或單元格區域中的多個值連接在一起。

請注意,該函數僅在 Excel for Office 365、Excel 2021 和 Excel 2019 中可用。

要將列列表轉換為逗號分隔列表,請選擇一個空白單元格,例如單元格 C1,然後鍵入此公式 =TEXTJOIN(", ",TRUE,A1:A7) (A1:A7 是將轉換為逗號鋸齒列表的列, “” 指示您希望如何分隔列表)。 請看下面的截圖:


使用CONCATENATE函數將列列表轉換為逗號分隔的列表

在Excel中,CONCATENATE函數可以將列列表轉換為以逗號分隔的單元格中的列表。 請執行以下操作:

1。 選擇一個與列表的第一個數據相鄰的空白單元格,例如單元格C1,然後鍵入此公式 = CONCATENATE(TRANSPOSE(A1:A7)&“,”) (A1:A7 是將轉換為逗號鋸齒列表的列, “,” 表示要分隔列表的分隔符)。 請參閱下面的屏幕截圖:

2。 突出顯示 TRANSPOSE(A1:A7)&“,” 在公式中,然後按 F9 鍵。

3。 除去花括號 { } 從公式中,然後按 Enter 鍵。

現在,您可以看到列列表中的所有值都已轉換為單元格中的列表並以逗號分隔。 參見上面的截圖。

使用Kutools for Excel快速將列列表轉換為逗號分隔的列表

Kutools for Excel的 合併列或行而不丟失數據 實用程序可以幫助Excel用戶輕鬆地將多列或多行合併為一列/行,而不會丟失數據。 此外,Excel用戶可以將這些組合的文本字符串用回車或硬回車換行。


使用VBA將列列表轉換為逗號分隔的列表

如果CONCATENATE函數對您來說有點繁瑣,則可以使用VBA快速將列列表轉換為單元格中的列表。

1。 保持 ALT 按鈕並按下 F11 在鍵盤上打開一個 Microsoft Visual Basic應用程序 窗口。

2。 點擊 插入 > 模塊,然後將VBA複製到模塊中。

VBA:將列列表轉換為逗號分隔的列表

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。 點擊 按鈕或按下 F5 運行VBA。

4。 屏幕上顯示一個對話框,您可以選擇要轉換的列列表。 看截圖:

5。 點擊 OK,然後彈出另一個對話框供您選擇一個單元格。 看截圖:

6。 點擊 OK,並且列列表中的所有值都已轉換為一個單元格中用逗號分隔的列表。

尖端:在上面的VBA中,“,”表示您需要的分隔符,您可以根據需要進行更改。


使用Kutools for Excel將列列表轉換為逗號分隔的列表

您也可以將Kutools用於Excel的 結合 組合列列表的實用程序,並輕鬆地用逗號分隔每個值。

Excel的Kutools - 使用 300 多種基本工具增強 Excel 功能。 享受全功能 30 天免費試用,無需信用卡! 立即行動吧!

1。 選擇要轉換為逗號分隔列表的列列表,然後單擊 庫工具 > 合併和拆分>合併行,列或單元格而不會丟失數據.

2。 在打開的“合併列或行”對話框中,您需要:
(1)檢查 合併行 在選項 根據以下選項合併選定的單元格 部分;
(2)在 指定分隔符 部分,檢查 其他分隔符 選項,然後鍵入逗號 , 進入下面的盒子;

3。 點擊 Ok 按鈕。

現在,您將看到指定列列表中的所有值都合併到一個單元格中,並轉換為逗號分隔的列表。

Excel的Kutools - 使用 300 多種基本工具增強 Excel 功能。 享受全功能 30 天免費試用,無需信用卡! 立即行動吧!


演示:在Excel中將列列表轉換為逗號分隔的列表


Excel的Kutools:超過 300 個方便的工具觸手可及! 立即開始 30 天免費試用,沒有任何功能限制。 現在就下載!

反向串聯並將一個單元格(逗號鋸齒狀列表)轉換為Excel中的行/列列表

通常,Excel用戶可以應用 文本到列 該功能可將一個單元格拆分為多列,但是沒有直接方法將一個單元格轉換為多行。 但是,Kutools for Excel的 分裂細胞 實用程序可以幫助您輕鬆完成此操作,如下圖所示。



相關文章:

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