- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Remove/Delete All Spaces After the Last Character in Excel?
We will walk you through a straightforward, step-by-step procedure in this article to effectively clean up your data and get rid of any trailing spaces that might be resulting in errors or problems in your Excel sheets. Even though they frequently go unnoticed, trailing spaces can cause unanticipated issues when completing calculations, sorting data, or generating reports.
Whatever your level of Excel proficiency, this course will be suitable for both newcomers and more seasoned users, offering clear instructions and helpful pointers along the way. Make sure you have a basic understanding of Microsoft Excel and that it is installed on your computer before we start. Let's get your data organised and create a cleaner, more effective Excel workbook.
Remove/Delete All Spaces After the Last Character
Here we will first create a VBA module to select the range of cells to complete the task. So let us see a simple process to know how you can remove or delete all spaces after the last character in Excel.
Step 1
Consider an Excel sheet where you have a list of strings with spaces after the last character, similar to the below image.
First, right-click on the sheet name and select View code to open the VBA application.
Right-click > View Code.
Step 2
Then click on Insert and select Module, then copy the below code into the text box.
Insert > Module > Copy.
Code
Sub NoSpaces() Dim xRg As Range Dim xTxt As String Dim xCell As Range On Error Resume Next If ActiveWindow.RangeSelection.Count > 1 Then xTxt = ActiveWindow.RangeSelection.AddressLocal Else xTxt = ActiveSheet.UsedRange.AddressLocal End If Set xRg = Application.InputBox("Please select range:", "Remove Spaces Last", xTxt, , , , , 8) If xRg Is Nothing Then Exit Sub Application.ScreenUpdating = False For Each xCell In xRg xCell.Value = RTrim(xCell.Value) Next Application.ScreenUpdating = True End Sub
Step 3
Then click F5 to run the module. Then select the range of cells and click OK to complete the task. Then you will see that all the spaces after the last character will be removed.
F5 > Select Cells > OK
This is how you can remove spaces after the last character in Excel.
Conclusion
In this tutorial, we have used a simple example to demonstrate how you can remove or delete all spaces after the last character in Excel to highlight a particular set of data.