跳到主要內容

如何合併多個單元格的內容而不丟失Excel中的數據?

我們可能會經常在Microsoft Excel中合併單元格及其內容。 但是,您是否找到組合單元格內容的最簡單方法? 在這裡,我們將討論如何輕鬆快速地合併Excel中的單元格內容。

使用VBA代碼將多個單元合併為一個單元
使用Kutools for Excel將多個單元格合併為一個單元格而不會丟失數據


使用VBA代碼將多個單元合併為一個單元

以下VBA代碼可以幫助您將多個單元格合併為一個單元格,並且可以通過以下步驟應用代碼:

1。 點擊 開發者 > Visual Basic中,一個新的 適用於應用程序的Microsoft Visual Basic 將顯示一個窗口,單擊 插入 > 模塊,然後將以下代碼輸入到模塊中:

Sub MergeOneCell()
'Updateby20140128
Dim Rng As Range
Dim WorkRng As Range
Dim Sigh As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Sigh = Application.InputBox("Symbol merge", xTitleId, "", Type:=2)
xOut = ""
Application.DisplayAlerts = False
For Each Rng In WorkRng
    xOut = xOut & Rng.Value & Sigh
Next
With WorkRng
    .Merge
    .Value = VBA.Left(xOut, VBA.Len(xOut) - 1)
End With
Application.DisplayAlerts = True
End Sub

2。 然後點擊 文檔乘法計算 3 按鈕執行代碼。 彈出一個對話框,供您選擇要使用VBA的範圍。 查看屏幕截圖:

3。 點擊 Ok,將顯示另一個對話框供您指定分隔符。 看截圖:

doc合併單元格內容2

4。 點擊 Ok,然後將所選範圍內的單元格內容合併到一個單元格中。 看截圖:

doc合併單元格內容3


使用Kutools for Excel將多個單元格合併為一個單元格而不會丟失數據

如果你有 Excel的Kutools 安裝後,您可以方便地組合多個列或行的單元格內容,而無需使用公式。

1。 選擇要合併數據的單元格。 並通過單擊應用此實用程序 庫工具 > 合併與拆分 > 合併行,列或單元格而不會丟失數據.

2。 在 合併列或行 對話框中,指定所需的選項。 看截圖:

  • (1.)選擇 合併成單個單元格根據以下選項合併選定的單元格;
  • (2.)指定合併數據的分隔符。 您可以用空格,任何內容,分號或特定文本分隔每個內容。 您還可以在新行中顯示合併的內容。

doc合併單元格內容5

3。 然後點擊 OK or 登記,多個單元格中的所有數據已合併到一個單元格中。 看截圖:

注意:該實用程序還可以幫助合併選定列的單元格。 您可以將名字和姓氏合併為一個全名單元格,如下圖所示。

然後,您可以看到名字和姓氏被合併並位於全名單元格中。

  如果您想免費試用(30天)此實用程序, 請點擊下載,然後按照上述步驟進行操作。


相關文章


演示:將多個單元合併/合併為一個單元而不會丟失數據

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!

Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
my earlier query is about this vba:Sub MergeOneCell() 'Updateby20140128 Dim Rng As Range Dim WorkRng As Range Dim Sigh As String On Error Resume Next xTitleId = "KutoolsforExcel" Set WorkRng = Application.Selection Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8) Sigh = Application.InputBox("Symbol merge", xTitleId, ",", Type:=2) xOut = "" Application.DisplayAlerts = False For Each Rng In WorkRng xOut = xOut & Rng.Value & Sigh Next With WorkRng .Merge .Value = VBA.Left(xOut, VBA.Len(xOut) - 1) End With Application.DisplayAlerts = True End Sub Between, what does the type here, "8" & "2" refers to
This comment was minimized by the moderator on the site
how repeat the process if i have 4 different reference and need to combine them one after the other
This comment was minimized by the moderator on the site
Awesome! Greatly helps! Thank you so much!
This comment was minimized by the moderator on the site
how to merge 2 cell ex:-[a1:41.00] [B1:kWh] [C1:041.00 kWh]
This comment was minimized by the moderator on the site
Thanks very much - was a big help!
This comment was minimized by the moderator on the site
Thamks a lot for the code. Was very helpful.
This comment was minimized by the moderator on the site
Very helpful thank you took me a while to find it but was just what I needed. Note in the VBA code if you want to seperate data with a semicolon, comma or some other charater in the "delim = " " " field put you charater betwen the quotes example: delim = ";". Thanks again.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations