Title: How to remove leading and trailing spaces in Excel cells?
Headings: How to remove leading and trailing spaces in Excel cells?
How to remove leading and trailing spaces in Excel cells?
Method A: Remove all extra spaces from strings with the TRIM function (2 steps)
Remove extra spaces from strings
=TRIM (B2)
Tip:
Remove all excess spaces including non-printing characters and non-breaking space
=TRIM (CLEAN (SUBSTITUTE (B2,CHAR (160)," ")))
Note:
Method B: Remove leading spaces from strings with the VBA code (5 steps)
1. Press Alt + F11 key to enable Microsoft Visual Basic for Applications window.
VBA: Deleting leading spaces from string
Note:
Method C: Remove leading/trailing/extra/all spaces as you need with Kutools (3 steps)
Remove Leading Spaces only:
Remove Trailing Spaces only:
Remove Leading & Trailing Spaces only:
Remove All Excess Spaces:
Remove All Spaces:
Demo: Remove Spaces
Download sample file
Other Operations (Articles) Related To File Conversion
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
Office Tab - brings tabbed interface to Office, and make your work much easier

Content: Select a cell next to the cell you want to remove extra spaces from string, type this formula
=TRIM (B2)
B2 is the cell you want to remove spaces from, See screenshot: 2. Press Enter key to get the result then drag auto fill handle over the cells you want to remove extra spaces from, all of leading spaces and trailing spaces and extra spaces have been removed. Tip: 1. You can copy and paste the formula results as value as below screenshot shown: 2. This method is quite easy if you only need to remove spaces in contiguous cells within a row or a column. However, when you need to remove leading spaces in a range with several rows and columns, you have to use the function several times. In this case, you can try method C.
Remove all excess spaces including non-printing characters and non-breaking space
If there are some non-printing characters in your string such as appeared in Excel as CHAR (160), they cannot be removed successfully with the TRIM function.