如何基于Excel中的組將行連接到一個單元格中?

      網友投稿 414 2025-03-31

      如何基于Excel中的組將行連接到一個單元格中?

      這是兩列的范圍,一列是班級列表,另一列是學生姓名列表。 如您所見,有些學生在同一堂課,有些則不在。 現在,我想將同一班級的學生連接到一個單元格中,如下面的屏幕截圖所示,如何在Excel中快速處理它?

      用公式和過濾器功能分組和連接

      分組并連接VBA代碼

      分組并連接“高級合并行”

      用公式和過濾器功能分組和連接

      在Excel中,您可以將公式應用于基于一列的串聯行,然后使用“篩選器”功能僅顯示結果。

      備注:在執行以下步驟之前,您需要按類對數據進行排序。

      1.在數據范圍旁邊的空白單元格中,例如C13,鍵入此公式 =IF(A13=A12,C12&", "&B13,B13), 按 Enter

      鍵,然后拖動填充手柄將公式填充到單元格中。

      在公式中,A13是“類別”列中的第一個數據,B13是“名稱”列中的第一個數據,“,”是用于分隔連接內容的分隔符。

      2.然后在下一列D13中鍵入此公式 =IF(A13<>A14,"Last","")

      如何基于Excel中的組將行連接到一個單元格中?

      ,然后向下拖動填充手柄以將公式應用于所需的單元格。

      3.現在選擇所有數據范圍,包括公式,然后單擊 Data > Filter 添加 Filter icons

      數據。

      4。 點擊 Filter icon 在最后一個公式標題中,檢查 Last 僅從下拉列表中選中復選框,然后單擊 OK

      .

      現在結果顯示如下,如果不需要,您可以刪除最后一個幫助器列。

      分組并連接VBA代碼

      這是一個VBA代碼,也可以處理此工作。

      1。 按 Alt + F11 啟用 Microsoft Visual Basic for Applications 窗口。

      2.然后在窗口中,單擊 Tools > References 啟用 References 對話框,然后檢查 Microsoft Scripting Runtime

      。 看截圖:

      3。 點擊 OK和點擊 Insert > Module 在VBA窗口中,然后將以下VBA代碼復制并粘貼到 Module 腳本。 看截圖:

      VBA:根據組將行連接到一個單元格中

      Sub ConcatenateCellsIfSameValues() UpdatebyExtendoffice20180201 Dim I As Long Dim J As Long Dim xRg As Range Dim xRgKey As Range Dim xRgVal As Range Dim xStr As String Dim xDic As New Dictionary On Error Resume Next Set xRg = Application.InputBox("Select data range", "KuTools for Excel", Selection.Address, , , , , 8) If xRg Is Nothing Then Exit Sub Set xRgKey = Application.InputBox("Select key column", "KuTools for Excel", xRg.Columns(1).Address, , , , , 8) If xRgKey Is Nothing Then MsgBox "Key column cannot be empty", vbInformation, "KuTools for Excel" End If Set xRgVal = xRg(1).Offset(, 1).Resize(xRg.Rows.Count, xRg.Columns.Count - 1) For I = 1 To xRgKey.Count If I > xRgKey.Count Then Exit For xStr = "" For J = 1 To xRgVal.Columns.Count xStr = xStr & " " & xRgVal(I, J) Next If xDic.Exists(xRgKey(I).Text) Then xDic(xRgKey(I).Text) = xDic(xRgKey(I).Text) & xStr xRgKey(I).EntireRow.Delete I = I - 1 Else xDic.Add xRgKey(I).Text, xStr End If Next For I = 1 To xRgVal.Count xRgVal(I).Value = xDic(xRgKey(I).Text) Next End Sub
      Copy
      4. Press F5 key, and select the data range you use in the popping dialog. 5. Click OK to select the key column you want to group based on. 6. Click OK, now the result is shown as below: Group and concatenate with Advanced Combine Rows Here is a utility in Kutools for Excel, Advanced Combine Rows, which can combine rows or do calculations based on a key column in Excel. Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. Free Downloadfree full-featured in 30 days After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!) 1. Select the data range you use and click Kutools > Merge & Split > Advanced Combine Rows. 2. In the Advanced Combine Rows window, choose the column which you want to combine rows based on, and click Primary Key to set it as key column. 3. Select the column you need to combine, click Combine, and choose one delimiter you use to separate the combined contents. 4. Click Ok. The result is shown as this: Note: Before apply the utility, you had better have a copy of the original data. Demo Best Office Productivity Tools Transform Hours into Minutes with Kutools for Excel! Ready to supercharge your Excel tasks? Harness the power of Kutools for Excel - your ultimate time-saving tool. Streamline intricate tasks and glide through your data like a pro. Experience Excel at lightning speed! Why You Need Kutools for Excel ??? Over 300 Powerful Features: Kutools is packed with more than 300 advanced features, simplifying your work in over 1500 scenarios. ?? Superior Data Processing: Merge cells, remove duplicates, and perform advanced data conversions – all without breaking a sweat! ?? Efficient Batch Operations: Why put in extra effort when you can work smart? Import, export, combine, and tweak data in bulk with ease. ?? Customizable Charts and Reports: Access a broad variety of additional charts and generate insightful reports that tell a story. ??? Powerful Navigation Pane: Gain an advantage with the robust Column Manager, Worksheet Manager, and Custom Favorites. ?? Seven Types of Drop-down Lists: Make data entry a breeze with drop-down lists of various features and types. ?? User-Friendly: A breeze for beginners and a powerful tool for experts. Download Now and Soar Through Time with Excel! Read More... Free Download... Purchase... Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project. Open and create multiple documents in new tabs of the same window, rather than in new windows. Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day! Read More... Free Download... Purchase...

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:如何運轉私域流量(1分鐘之前已更新)
      下一篇:Excel2010中如何插入自定義的頁眉和頁腳并輸入自定義內容(excel設置頁眉和頁腳的操作方法是什么)
      相關文章
      精品国产日韩亚洲一区91| 亚洲高清视频免费| 亚洲国产成人久久三区| 亚洲精选在线观看| 亚洲gv猛男gv无码男同短文| MM131亚洲国产美女久久| 成a人片亚洲日本久久| 亚洲av无码无线在线观看| 亚洲精华国产精华精华液网站| 亚洲国产成a人v在线观看| 亚洲一级毛片免费在线观看| 亚洲人成网站在线观看播放动漫 | 亚洲无码精品浪潮| 亚洲精品456播放| MM131亚洲国产美女久久| 国产亚洲美女精品久久久2020| 在线观看亚洲精品国产| 亚洲综合伊人久久大杳蕉| 亚洲人成伊人成综合网久久久| 亚洲午夜久久久影院伊人 | 亚洲最大的成人网| 亚洲AV综合永久无码精品天堂| 精品国产亚洲第一区二区三区 | 在线亚洲v日韩v| 亚洲 综合 国产 欧洲 丝袜| heyzo亚洲精品日韩| 亚洲综合区小说区激情区| 久久99国产亚洲高清观看首页| 亚洲Av综合色区无码专区桃色| 亚洲三级电影网站| 亚洲av永久无码精品三区在线4| 在线综合亚洲欧洲综合网站 | 亚洲电影中文字幕| 亚洲精品成人久久| 亚洲国产成人精品激情| 婷婷亚洲综合五月天小说在线| 亚洲欧洲中文日韩av乱码| 国产亚洲3p无码一区二区| 久久亚洲精品无码AV红樱桃| 亚洲国产精品综合久久网各| 亚洲精品伦理熟女国产一区二区|