跳到主要內容

如何通過回車將單元格分為多列或多行?

通常,在Excel中,我們可以使用“文本到列”功能根據某些特定字符(例如逗號,分號,點標記)將單元格內容快速拆分為多列。 但是,您是否曾經嘗試通過回車符將單元格值分成多列或多行?

根據回車和“文本到列”將單元格分成多列

使用VBA代碼根據回車將單元格分成多行

使用Kutools for Excel根據回車將單元格分為多列或多行

使用Kutools for Excel根據回車將多個單元格合併為一個


箭頭藍色右氣泡 根據回車和“文本到列”將單元格分成多列

如果您具有由回車符分隔的單元格內容列表,如下所示,則實際上是 文本到列 函數可以幫助您將單元格值分成多列。

doc由新行1分割

1。 選擇要拆分其內容的單元格。

2。 點擊 數據 > 文本到列,請參見屏幕截圖:

doc由新行2分割

3。 在 將文本轉換為列嚮導,檢查 分隔 步驟1中的選項,請參見屏幕截圖:

doc由新行3分割

4。 然後點擊 下一頁 按鈕,在步驟2中,檢查 其他 選項下 定界符,然後在旁邊的框中 其他, 按 Ctrl + J 鑰匙,請看截圖:

doc由新行4分割

5。 然後點擊 下一頁 按鈕,在步驟3中,選擇 選項,並指定用於定位結果的單元格,然後單擊 直接按一下按鈕即可完成操作。

doc由新行5分割

6。 單元格內容已分為多列,如以下屏幕截圖所示:

doc由新行6分割


箭頭藍色右氣泡 使用VBA代碼根據回車將單元格分成多行

有時,您需要根據回車符將單元格值分成多行,如下面的屏幕截圖所示。

doc由新行7分割

您沒有直接的方法可以在Excel中處理此任務,但是可以創建VBA代碼來解決它。

1。 按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications窗口.

2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊窗口.

VBA代碼:根據回車符將單元格分成多行

Sub SplitCells()
'Update by Extendoffice
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    lLFs = VBA.Len(Rng) - VBA.Len(VBA.Replace(Rng, vbLf, ""))
    If lLFs > 0 Then
        Rng.Offset(1, 0).Resize(lLFs).Insert shift:=xlShiftDown
        Rng.Resize(lLFs + 1).Value = Application.WorksheetFunction.Transpose(VBA.Split(Rng, vbLf))
    End If
Next
End Sub

3。 然後按 F5 鍵來運行此代碼,然後會彈出一個提示框,提醒您選擇要拆分的數據范圍,請參見屏幕截圖:

doc由新行8分割

4。 然後點擊 OK,並且根據回車將您選擇的數據分為多行。


箭頭藍色右氣泡 使用Kutools for Excel根據回車將單元格分為多列或多行

Excel的Kutools分裂細胞 實用程序可以幫助您快速輕鬆地將單元格拆分為多列或多行。

Excel的Kutools : 帶有300多個便捷的Excel加載項,可以在30天內免費試用. 

安裝後 Excel的Kutools,請執行以下操作:

1。 選擇要拆分的數據范圍。

2。 點擊 庫工具 > 合併與拆分 > 分裂細胞,請參見屏幕截圖:

3。 在 分裂細胞 對話框中,選擇 拆分為行 or 拆分為列 選項下 類別 您需要的部分,然後檢查 新隊指定分隔符 部分,請參見屏幕截圖:

doc由新行10分割

4。 然後點擊 OK 按鈕,然後會彈出一個提示框,提醒您選擇一個單元格以輸出結果,請參見屏幕截圖:

doc由新行11分割

5。 然後點擊 OK,如果您選擇 拆分為列 選項,所有選擇的單元格值都已由回車符分成多列,請參見屏幕截圖:

doc由新行12分割

如果你選擇 拆分為行 選項,您選擇的單元格值將被分成多行,如下面的屏幕截圖所示:

doc由新行13分割

單擊以了解有關此“拆分單元格”實用程序的更多信息……

點擊下載並立即免費試用Excel的Kutools!


箭頭藍色右氣泡 演示:根據回車和“文本到列”將單元格拆分為多列

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

箭頭藍色右氣泡 使用Kutools for Excel根據回車將多個單元格合併為一個

根據回車符將多個單元格合併為一個:

與上述內容相反,如何將多個用回車符分隔的單元格值組合到Excel中的一個單元格中? 在這裡,我將討論一個簡單的工具-Excel的Kutools,其功能強大 結合 功能,您可以快速將多個行,列,單元格合併為一個單元格。

doc由新行14分割

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!


箭頭藍色右氣泡 演示:使用Kutools for Excel根據回車將多個單元格合併為一個

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即下載並免費試用!

相關文章:

如何在Excel中將回車轉換為逗號?

如何在Excel中快速刪除換行符?

最佳辦公生產力工具

🤖 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 (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I have values in cell like "100/5" which is fetched by formula in one cell and would like to split the values in to two adjacent columns like "100" in one cell and "5" in another. Could you please suggest if I can do that with help of formula?
This comment was minimized by the moderator on the site
This is awesome.. very helpful.. Thank you so much.. :)
This comment was minimized by the moderator on the site
Hi, If this formula contains the option to insert instead directly split and paste in a transpose method, we do have range of rows, This option just split and transpose on existing data cells. If we get a option to insert and paste accordingly would be grateful otherwise the formula is very useful
This comment was minimized by the moderator on the site
This page has helped a lot, I used to VBA to separate the rows up. The problem that I have is that I have multiple columns. All the cells in the row either have one "row" or X number of "rows"of information in the other cells. If anyone knows how to do this it would be greatly appreciated.
This comment was minimized by the moderator on the site
[quote]This page has helped a lot, I used to VBA to separate the rows up. The problem that I have is that I have multiple columns. All the cells in the row either have one "row" or X number of "rows"of information in the other cells. If anyone knows how to do this it would be greatly appreciated.By Brian[/quote] Stephen Even i'm looking for multiple Column having Alt+Enter data needs to convert to multiple rows with same data , needs copy the entire data of next columns as well in the new row
This comment was minimized by the moderator on the site
Was looking for information like this and this page solved everything for me. Well done!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations