Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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.

Remove leading spaces in cells with Trim function

Remove leading spaces in cells with VBA

Remove leading spaces in cells with Kutools for Excelgood idea3


arrow blue right bubble Remove leading spaces in cells with Trim function

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.


Quickly remove extra/leading/trailing spaces in Excel sheet

  Click for full-featured free trial in 60 days!
doc remove spaces
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in full future 60 days.

arrow blue right bubble Remove leading spaces in cells with VBA

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:


arrow blue right bubble Remove leading spaces in cells with Kutools for Excel

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: A handy Excel add-in tool,makes your jobs more easier and efficiency.
  • 300+ powerful and easy-to-used functions,110,000+ Excel users'choice
  • full-featured free trial in 60 days, no credit card required
  • dozens of one-click functions to shrink your working time on solving complex problems
  • includes functions to batch converion,deletion,combining sheets/cells,exproting, ect, free try now.

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:

doc remove leading spaces 5

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:

doc remove leading spaces 6

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
doc remove leading spaces 7
Remoev extra spaces -- check All excess spaces option
doc remove leading spaces 8
Remoev all spaces -- check All spaces option
doc remove leading spaces 9

arrow blue right bubble Remove leading spaces in cells with Kutools for Excel

Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!

You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free 45-day trial of Office Tab!

ot excel

Related articles:



Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 300 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...

Screen shot of Kutools for Excel

Say something here...
symbols left.
You are guest ( Sign Up? )
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.
    narendra · 26 days ago
    awesome sir...
  • To post as a guest, your comment is unpublished.
    Angel One · 2 months ago
    Excelente aportación
  • To post as a guest, your comment is unpublished.
    Koala · 2 months ago
    THANKS GUYS SAVED MY LIFE!!!!!
  • To post as a guest, your comment is unpublished.
    Daniel Musyoka · 7 months ago
    KUTOOLS is one of the greatest Excel add-ins ever. Great insights above.
  • To post as a guest, your comment is unpublished.
    Sam Ried · 7 months ago
    Thanks for this wonderful article! hats off to your writing! great post with rich quality content! Very resourceful and informative! Keep posting! Would love to follow up on your upcoming future posts! Ninja Heroes Mod Apk