How to Clear Unwanted Spaces in Excel Cells

To remove all ordinary spaces in Excel, use Find and Replace with one space in Find what and an empty replacement, or use a SUBSTITUTE formula.

Contents

Don't Miss the Good Stuff

Get tech news that matters delivered to your inbox.

To remove all ordinary spaces in Excel, select the cells, open Find & Select > Replace, enter one space in Find what, leave Replace with empty, and select Replace All. This deletes ordinary spaces everywhere in the selected text, including between words. To preserve single spaces between words while clearing extra spacing, use =TRIM(A2) in an empty cell instead.

The desktop replacement steps apply to Excel for Microsoft 365 and Excel 2024 on Windows and Mac, with a separate path for Excel for the web. Before changing the original cells, you can copy a worksheet in Excel to keep an original copy.

The short version

  • Remove every ordinary space: Replace one space with an empty replacement in the selected cells.
  • Keep readable word spacing: Use TRIM to remove outer spaces and reduce repeated spaces between words to one.
  • Keep the original column: Use SUBSTITUTE in a separate column, then fill the formula down.
  • Handle stubborn spaces: Nonbreaking spaces need a targeted replacement because TRIM does not remove them.

MethodBest useMain catch
Find and ReplaceDelete every ordinary space in placeAlso joins words together
Replace double spaces with single spacesReduce repeated ordinary spacesLeaves one leading or trailing space
SUBSTITUTERemove ordinary spaces in a separate columnResults remain formulas until pasted as values
TRIMKeep single spaces between wordsLeaves nonbreaking spaces untouched
SUBSTITUTE with UNICHARTarget nonbreaking spacesOther Unicode spaces need their own code points
CLEAN with a space formulaRemove tabs, line breaks, and unwanted ordinary spacesDoes not remove every invisible character
Flash FillClean text from examplesInferred results need review
Manual editingRemove selected spaces in one cellRequires editing each affected cell
Clear ContentsEmpty cells containing only unwanted spacesRemoves the entire cell value
Alignment and indentationCorrect visible gaps without changing textDoes not delete space characters
Clear FormatsRemove padding caused by formattingAlso removes other formatting

Remove all spaces with Find and Replace

Select the cells you want to clean before opening the replacement controls. Removing every space turns text such as AB 12 CD into AB12CD, so use this method when the gaps should disappear completely. For names or sentences that still need spaces between words, use TRIM instead.

On Windows, choose Home > Editing > Find & Select > Replace, or press Ctrl + H. On Mac, choose Home > Find & Select > Replace, or press Control + H. Enter one ordinary space in Find what and leave Replace with completely empty.

Uncheck Match entire cell contents so Excel can replace spaces within longer text. Select Replace All to clean the selected cells, or select Replace to review individual replacements. Check the results to confirm that words or parts of an identifier have joined as intended.

In Excel for the web, select the range and choose Home > Editing > Find & Select > Replace. Enter one space in Find what, leave Replace with empty, then expand Search Options and set Within to Selection. Uncheck Match entire cell contents and select Replace All.

Remove spaces in a separate column

A formula lets you keep the original text while creating a cleaned result beside it. With your source text in A2, select an empty cell in another column and enter this formula:

=SUBSTITUTE(A2," ","")

Press Enter, then fill the formula down for the remaining rows. The space inside the first pair of quotation marks is the character Excel replaces, and the empty quotation marks provide its replacement. Every matching ordinary space is removed because the formula does not specify a particular occurrence.

Compare the original and cleaned columns before replacing the source values. The output still depends on the source cells until you paste it as values, so leave the source column in place while reviewing the results.

Keep single spaces between words

For names, addresses, or other readable text, deleting every space may go too far. TRIM removes leading and trailing ordinary spaces and reduces repeated ordinary spaces between words to one. With the original text in A2, enter this formula in an empty cell:

=TRIM(A2)

Press Enter and fill down to clean the rest of the column. Text such as Mary Jones becomes Mary Jones, preserving the gap between the two words. Nonbreaking spaces remain, so use the next method when unwanted gaps survive trimming.

Find and Replace can also collapse repeated ordinary spaces without a formula. Open Replace, search for two spaces, replace them with one, and select Replace All repeatedly until no double spaces remain. That approach still leaves one leading or trailing space, so use TRIM when you also need to remove outer spaces.

Fix nonbreaking spaces and invisible characters

A space that survives ordinary replacement or trimming may be a nonbreaking space. In desktop Excel for Microsoft 365 or Excel 2024, enter this formula in an empty cell to convert nonbreaking spaces to ordinary spaces and then normalize the spacing:

=TRIM(SUBSTITUTE(A2,UNICHAR(160)," "))

Press Enter and fill down as needed. This keeps single spaces between words while removing extra ordinary spacing around them. To delete both ordinary and nonbreaking spaces everywhere instead, use this formula:

=SUBSTITUTE(SUBSTITUTE(A2,UNICHAR(160),"")," ","")

Tabs and line breaks need a different cleanup. CLEAN removes supported ASCII control characters, including tabs and line breaks, but it does not remove ordinary spaces on its own. To remove those control characters and ordinary spaces together, enter:

=SUBSTITUTE(CLEAN(A2)," ","")

For readable text that should retain single ordinary spaces between words, use =TRIM(CLEAN(A2)) instead. Removing a tab or line break deletes that character rather than inserting a separating space, so review the resulting word boundaries. Neither approach removes every possible Unicode invisible character; for another identified Unicode space, replace 160 in the earlier targeted formula with that character's code point.

Replace the original cells with cleaned values

Once the formula results look right, copy the cleaned cells and select the original destination cells. Choose Home > Paste > Paste Special > Values. This replaces the destination with the cleaned text rather than formulas that depend on the source column.

Verify the pasted values before removing the helper column. If copying or pasting fails, fix cut and paste in Excel before continuing. Keep the helper column until the paste succeeds.

Review any entries that now look identical after their spacing has changed. If you also need to find and remove duplicates in Excel, do that after checking the cleaned values.

Use Flash Fill for cleanup from examples

Flash Fill is another option in Excel for Microsoft 365 and Excel 2024 on Windows and Mac. Beside the source column, type the first cleaned result and press Enter. Select the next output cell, then choose Data > Flash Fill.

Alternatively, start typing another cleaned example and press Enter when the preview is correct. Review the entire output because Flash Fill infers a pattern and can make mistakes. If the results do not follow the spacing rule you need, use SUBSTITUTE to delete ordinary spaces or TRIM to preserve single spaces between words.

On Windows, you can enable automatic Flash Fill through File > Options > Advanced. Check Automatically Flash Fill, select OK, then close and restart Excel. Supply the cleaned examples in an adjacent column after reopening the app.

Fix gaps caused by formatting

Before repeating a cleanup that changes nothing, select an affected cell and inspect its text in the formula bar. When the text contains no unwanted space characters, alignment or indentation may be creating the visible gap. Select the cells and choose Home > Alignment > Align Left, then use Decrease Indent to undo indentation.

Custom number formatting can also create apparent padding. Choose Home > Editing > Clear > Clear Formats to remove formatting while retaining cell contents. This removes other formatting too, so use it only when that broader change is acceptable.

For a single cell with actual unwanted spaces, you can edit the text directly. On Windows, select the cell and press F2, select the unwanted spaces, press Delete, then press Enter. For cells containing only spaces whose entire contents should disappear, select only those cells and choose Home > Editing > Clear > Clear Contents.

Frequently Asked Questions

Can Excel remove spaces and convert the result to a number?

Use =NUMBERVALUE(A2) for numeric text; it ignores spaces even between digits. You can specify imported separators, such as =NUMBERVALUE(A2,",","."). Avoid this for identifiers whose leading zeros must remain, because numeric conversion discards those zeros.

Can you remove outer spaces without changing internal spacing?

In Excel for Microsoft 365, use =REGEXREPLACE(A2,"^ +| +$","") to remove leading and trailing ordinary spaces while leaving internal spacing unchanged. You can use REGEXREPLACE on Windows, Mac, and the web, but Excel 2024 does not list support for it.

How do you remove spaces on an iPhone or Android device?

On iPhone or iPad, tap Search > Find, tap Options beside the search box, then choose Find and Replace or Find and Replace All. On Android, tap Find in the upper toolbar, open More Options, and choose Find and Replace All. Search for one space and leave the replacement empty; on Android, choose Sheet or Workbook for the scope, then run the replacement.

Does Power Query Trim work the same way as the TRIM formula?

Power Query Trim removes outer whitespace while preserving repeated internal spaces, whereas the TRIM formula also reduces repeated ordinary spaces between words to one. In Power Query Editor, select the text column and choose Transform > Format > Trim, then Home > Close & Load. To create a cleaned copy instead of changing the selected column, use Add Column > Format > Trim.

Share