Written by Allen Wyatt (last updated February 17, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, and Word in Microsoft 365
Sometimes when Eileen converts text to a table or if she imports a table from another program, some of the cells have a leading space in them, before the first actual character. She wonders if there is a way to use Find and Replace to remove these leading spaces only in the cells of the table.
There's actually one very quick way to get rid of the leading spaces without the need to use Find and Replace. Let's assume that you want the text in the cells to be left-aligned. Follow these steps:
That's it; when you perform step 3, the leading spaces are removed automatically by Word. Step 4 simply puts your text back to where you originally wanted it aligned. An extra bonus is that these steps actually remove any white space at the beginning of the text, not just spaces.
If you absolutely want to use Find and Replace to get rid of the spaces, you cannot do it using a single Find and Replace operation. Here's an idea of how you can do it using multiple passes:

Figure 1. The Replace tab of the Find and Replace dialog box.

Figure 2. The Find Style dialog box.
You could, if desired, also use a macro to remove leading spaces. All the macro needs to do is to step through all the cells in a table and trim off any leading spaces:
Sub DeleteCellLeadingSpace()
Dim aCell As Cell
Dim aRow As Row
Dim cText As String
If Selection.Information(wdWithInTable) Then
For Each aRow In Selection.Tables(1).Rows
For Each aCell In aRow.Cells
cText = aCell.Range.Text
cText = LTrim(cText)
aCell.Range.Text = Left(cText, Len(cText) - 2)
Next aCell
Next aRow
Else
MsgBox "Insertion point must be in a table."
End If
End Sub
Note that when this macro stuffs information back into a cell (from the cText variable), it only stuffs back everything but the final two characters. If you don't do this, you'll end up with an additional hard return in each cell of the table.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1263) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, and Word in Microsoft 365.
Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!
Left-justified tables are great for many document designs, but you may want instead to center a table between the margins ...
Discover MoreWhen you have a table that extends over multiple pages, you may want to have Word repeat a row or two at the top of each ...
Discover MoreSelecting rows and columns in tables is a common task. Because of this, Word provides a couple of ways you can accomplish ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-02-18 04:34:47
Ron S
A faster version of the the first tip is using shortcuts:
1. select the text
2. <CTL><E> (center align), <CTL><L> (left align)
That's it. Removes leading spaces and tabs.
Works on regular body text that is not in a table. (that is where I normally use it)
Actually, if you are repeatedly importing text from that web page to refresh you data a more round about approach may be better.
In Excel you can use PowerQuery to import that data, "data clean" it removing spaces and any other repetitive corrections it needs.
Save the Excel file
(first time only) Copy and Paste with link from Excel into Word.
I don't know if the PowerQuery refresh, to import new data and apply all data cleaning, works through the link. You MAY have to open the Excel file to refresh the linked data.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments