跳到主要內容

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

有時,當您從網站上複製一些數據或將值分開時, Alt + Enter鍵 鍵,您將獲得一些換行符或回車符,如果您想按如下所示的屏幕快照在Excel中快速刪除多個換行符,則可以按以下步驟完成:

文檔刪除換行符1 -2 文檔刪除換行符2

使用查找和替換功能刪除多個換行符

使用VBA代碼刪除多個換行符

使用Kutools for Excel刪除多個換行符


箭頭藍色右氣泡 使用查找和替換功能刪除多個換行符

您可以使用Excel中的查找和替換功能快速刪除多個換行符,請按以下步驟進行處理:

1。 選擇您要刪除多個換行符的範圍。

2。 點擊 首頁 > 查找和替換 > 更換 或點擊 Ctrl + F 快捷方式和 查找和替換 對話框將會彈出。

3. 然後在 查找內容 框,請按住 ALT 鍵,然後單擊數字 010 從數字鍵盤。 離開 更換 框為空白或輸入空格鍵。 看截圖:

文檔刪除換行符3

4。 然後點擊 “全部替換” 按鈕,所有換行符均已刪除。 看截圖:

文檔刪除換行符2


箭頭藍色右氣泡 使用VBA代碼刪除多個換行符

以下VBA代碼還可以幫助您刪除工作表中的所有換行符。 請這樣做:

1。 點擊 開發者 > Visual Basic中 或按 Alt + F11 鍵打開 Microsoft Visual Basic應用程序窗口,然後單擊 插入 > 模塊,然後輸入以下代碼:

VBA代碼:刪除工作表中的多個換行符

Sub RemoveCarriage()
'Update 20131216
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
    Rng.Value = Replace(Rng.Value, Chr(10), "")
Next
End Sub

2。 然後按 F5 鍵來運行此代碼,然後會出現一個提示框,提示您選擇要刪除換行符的範圍,請參見屏幕截圖:

文檔刪除換行符4

3。 然後點擊 OK 並且所選內容的所有換行符都已刪除。


箭頭藍色右氣泡 使用Kutools for Excel刪除多個換行符

在這種情況下,有時您可能會忘記如何使用“查找和替換”功能或不熟悉代碼來刪除多個換行符, Excel的Kutools 可以幫助你解決這個問題。

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

安裝Kutools for Excel之後,請執行以下步驟:

1。 選擇要刪除回車的範圍。

2. 點擊 庫工具 > 文本工具 > 刪除字符,請參見屏幕截圖:

文檔刪除換行符5

3。 在 刪除字符 對話框,檢查 非印刷 選項,您可以從中查看結果 預覽 窗格,請參見屏幕截圖:

文檔刪除換行符6

4。 然後點擊 OK or 登記。 所有的換行符將從選定的單元格中刪除。

單擊以了解有關此刪除字符功能的更多信息.


相關文章:

最佳辦公生產力工具

🤖 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
Obrigado pela dica! Funcionou muito bem aqui!
This comment was minimized by the moderator on the site
Thank You so much yaar. I found it very useful for my day to day office works.
This comment was minimized by the moderator on the site
Thank you very much. it is really superb
This comment was minimized by the moderator on the site
Thank you werry helpfull for my and my MYSQL CSV import :-)
This comment was minimized by the moderator on the site
THANK YOU!!! I have been battling blank lines in cell for too long. You solved the problem...thank you so much
This comment was minimized by the moderator on the site
I am very inexperienced when it comes to macros/VBA code. How would I tweak the code you provided above and which I have pasted below to search for 2 consecutive carriage returns and replace with just one carriage return? Sub RemoveCarriage() 'Update 20131216 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 Rng.Value = Replace(Rng.Value, Chr(10), "") Next End Sub Also, how would I locate and delete single carriage returns that have no text after them in a cell. Thank you for any assistance.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations