Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

如何從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中的單元格中刪除尾隨空格

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

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

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

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

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

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


演示:使用Kutools for Excel從選定的單元格中刪除尾隨空格


相關文章:


最佳辦公效率工具

Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及您以前使用過的任何東西; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
  • 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不會丟失數據; 拆分單元格內容; 合併重複的行/列...防止細胞重複; 比較範圍...
  • 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
  • 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
  • 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
  • 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
  • 超過300種強大功能。 支持Office / Excel 2007-2019和365。支持所有語言。 在您的企業或組織中輕鬆部署。 完整功能30天免費試用。 60天退款保證。
kte選項卡201905

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

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 每天將您的工作效率提高50%,並減少數百次鼠標單擊!
officetab底部
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mario · 3 years ago
    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!
  • To post as a guest, your comment is unpublished.
    Sakshi Sharma · 4 years ago
    Remove all white spaces after last character.
    Ex. "CABLE AS " it should become "CABLE AS"
    ("" not there in the cell)
  • To post as a guest, your comment is unpublished.
    umar jaan · 4 years ago
    You Made my life, feeling excited thanks for this micro code. SUUUUUUUUUUUUUUPPPERRRRR
  • To post as a guest, your comment is unpublished.
    Brian · 4 years ago
    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.
  • To post as a guest, your comment is unpublished.
    Sam · 4 years ago
    Awesome! Thanks! Saved a lot of time!!
  • To post as a guest, your comment is unpublished.
    Patrick Baldwin · 4 years ago
    WOW! Couldn't have been easier - thank you so much for the help!
  • To post as a guest, your comment is unpublished.
    Syed · 5 years ago
    Very good. Saved me a lot of time, thanks!
  • To post as a guest, your comment is unpublished.
    Paul D · 5 years ago
    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.
  • To post as a guest, your comment is unpublished.
    Vikash Sharma · 5 years ago
    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.
  • To post as a guest, your comment is unpublished.
    !MikeG! · 5 years ago
    Great article. Is there a way to tie the VBA code to a button?

    In order for the user to quickly hit and have the trailing spaces removed from a specific column.
  • To post as a guest, your comment is unpublished.
    Charles · 6 years ago
    Thanks for the macro to trim trailing spaces - easy, effective, and awesome.