跳到主要內容

如何從Microsoft Excel中的單元格中刪除尾隨空格?

假設您從其他人那裡獲得了一個Excel工作表,並且發現單元格末尾有多餘的空格。 而且這些尾隨空格不容易發現並影響單元格的排序,計算或其他操作。 本文將介紹幾種方法,以從Microsoft Excel中的單元格中刪除尾隨空格,如下所示。

使用VBA從Excel中的單元格中刪除尾隨空格
使用Kutools for Excel從Excel中的單元格中刪除尾隨空格


使用VBA從Excel中的單元格中刪除尾隨空格

使用“修剪”功能很容易刪除一個單元格中的尾部空格,但是刪除多個單元格中的尾部空格很費時間。 這裡提供了一個宏,用於刪除選擇中所有單元格的所有尾隨空格。

1:選擇要從單元格中刪除尾隨空格的範圍。

2。 按 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

3。 點擊 插入 > 模塊,然後將以下宏粘貼到“模塊窗口”中。

VBA代碼:從Excel中的選定單元格中刪除所有尾隨空格

Sub NoSpaces()
'Update by Extendoffice 20180613
Dim c As Range
For Each c In Selection.Cells
c = Trim(c)
Next
End Sub

4。 按 F5 運行此宏的鍵。 然後,立即將所有尾隨空格從選定範圍的單元格中刪除。


使用Kutools for Excel從Excel中的單元格中刪除尾隨空格

本節將介紹一個方便的插件- Excel的Kutools。 其 刪除空間 工具可以幫助您快速刪除單元格中的所有尾隨空格。 請做如下

申請前 Excel的Kutools首先下載並安裝.

1。 選擇要從單元格中刪除所有尾隨空格的範圍, 然後單擊 庫工具 > 文本 > 刪除空間.

2。 在 刪除空間 對話框,檢查 尾隨空格 選項 空間類型 部分,然後單擊 OK 按鈕。 看截圖:

然後,您可以看到所有尾隨空格已立即從選定的單元格中刪除。 看截圖:

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


演示:使用Kutools for 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 (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Gracias!!!
This comment was minimized by the moderator on the site
THANK YOU SO MUCH! I was going crazy doing a MS Word Mail merge from Excel data and couldn't figure out why there was extra space in the fields. MANY THANKS!
This comment was minimized by the moderator on the site
Remove all white spaces after last character. Ex. "CABLE AS " it should become "CABLE AS" ("" not there in the cell)
This comment was minimized by the moderator on the site
You Made my life, feeling excited thanks for this micro code. SUUUUUUUUUUUUUUPPPERRRRR
This comment was minimized by the moderator on the site
You might mention that you shouldn't select the entire worksheet as the range. It takes a very, very long time to process that many cells.
This comment was minimized by the moderator on the site
Awesome! Thanks! Saved a lot of time!!
This comment was minimized by the moderator on the site
WOW! Couldn't have been easier - thank you so much for the help!
This comment was minimized by the moderator on the site
Very good. Saved me a lot of time, thanks!
This comment was minimized by the moderator on the site
I solved it by copying the first formula in my 32 options I wanted to keep a part of the table, and pasted on the other 31 parts and the job was done.
This comment was minimized by the moderator on the site
Hello Frnds, Need help to resolve a problem. Problem: I have data in one single cell like as below: REQ-0001 REQ-00044 REQ-343543 (data is in single cell and having space in between). I want to just remove this breakline space and get the data in one single cell only as below: REQ-0001 REQ-00044 REQ-343543 Thanks in advance.
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