How to remove leading spaces in cells in Excel?
Sometimes there are some blank spaces before strings in cells, these spaces are called leading spaces. It must be arduous to remove leading spaces in cells one by one. Actually, there are several smart tricks that can help us remove leading spaces in cells conveniently and quickly. Suppose we paste some content from Microsoft Word with indent spaces, then it shows the leading spaces in each cell as the following screenshot shows.
One click to remove all leading zeros from cells in Excel
|Just one click, all leading zeros of the cells in seletion have been removed. Click for 60 days free trial!|
|Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days.|
Recommended Productivity Tools
The Trim function in Microsoft Excel can remove all spaces from text except for single spaces between words.
Step 1: Enter the formula =TRIM (A1) in the adjacent cell C1 and press the Enter key.
Step 2: Select cell C1 and drag the fill handle down to the range cell that you want to remove the leading space. Then you can see all cell content are extracted with all leading spaces removed. See screenshot:
You can replace the original content with the extracted ones by copying and pasting them as values.
This method is quite easy if you only need to remove leading 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.
If you are experienced with Microsoft Excel, VBA macro is a better choice to remove the leading spaces in cells.
Step 1: Hold down the Alt + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 2: Click Insert > Module, and paste the following macro in the Module window.
VBA: Remove leading spaces:
Sub RemoveLeadingSpace() 'Updateby20131129 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 = VBA.LTrim(Rng.Value) Next End Sub
Step 3: Press the F5 key to run this macro. In the pop-up KutoolsforExcel dialog box, you need to select a range with leading space you want to remove, and then click the OK button. See screenshot:
Then you can see all leading spaces are moved from the selected range, see screenshots:
If you have Kutools for Excel installed, you can remove all leading spaces of cells in a selection conveniently and quickly by its Remove Spaces utility.
|Kutools for Excel, with more than 120 handy functions, makes your jobs easier.|
After installing Kutools for Excel, please do as below:（Free Download Kutools for Excel Now!)
Step 1: Select the range which you want to remove all leading spaces in cells.
Step 2: Click the Kutools > Text > Remove Spaces. See screenshot:
Step 3: In the Remove Spaces dialog box, check the Leading Spaces option in Spaces Type section, and then click the OK or Apply button. See screenshot:
Now all leading spaces are removed from the selected cells.
Kutools for Excel's Remove Spaces tool makes it possible to delete all kinds of spaces from strings in cells, including all extra spaces, leading spaces, trailing spaces, or all spaces.
|Remoev trailing spaces -- check Trailig spaces option|
|Remoev extra spaces -- check All excess spaces option|
|Remoev all spaces -- check All spaces option|
Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!
- Remove trailing spaces from cells
- Remove spaces between character and numbers within cells
- Remove leading and trailing spaces
- Remove indents within cells
Recommended Productivity Tools
Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.
Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!
200 New Features for Excel, Make Excel Much Easy and Powerful:
- Merge Cell/Rows/Columns without Losing Data.
- Combine and Consolidate Multiple Sheets and Workbooks.
- Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
- Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
- More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 7 months agoIts very helpful
To post as a guest, your comment is unpublished.· 8 months agoThanks for sharing....
To post as a guest, your comment is unpublished.· 11 months agoSo, this is simply a marketing page for a product that has no need to exist?
To post as a guest, your comment is unpublished.
To post as a guest, your comment is unpublished.· 1 years agoThank you for sharing