Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Remove Extra Spacing in Excel: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To remove extra spacing in Excel, use the TRIM function to strip leading, trailing, and multiple internal spaces, then replace the original data with the cleaned values. For non-breaking spaces (CHAR(160)), combine TRIM with SUBSTITUTE. The whole process takes a few minutes and works in Excel for Microsoft 365, Excel 2021, 2019, and 2016 on Windows and Mac; menu labels can differ slightly by version, device, or region.

What You'll Need

  • Excel for Microsoft 365, Excel 2021, 2019, or 2016 (Windows or Mac). The steps below use the desktop app; Excel for the web has the same core functions but a slightly different ribbon layout.
  • A worksheet containing the text with extra spaces.
  • An empty column next to your data to hold the cleaned results.

Step-by-Step

  1. Make a backup copy of your sheet. Right-click the sheet tab and choose Move or Copy, tick Create a copy, and click OK. This protects your original data if a formula or paste step goes wrong.
  2. Identify the type of extra spacing. Click a cell with the problem and look at the Formula Bar. If you see normal spaces, TRIM will handle them. If the spaces look unusually wide or the text refuses to line up after TRIM, they may be non-breaking spaces, which need the SUBSTITUTE method in step 7.
  3. Insert a helper column. Click the column header to the right of your data, right-click, and choose Insert. Give it a label such as Cleaned in the first row.
  4. Enter the TRIM formula. In the first empty cell of the helper column, type =TRIM(A2) (replace A2 with the first cell of your messy data) and press Enter. TRIM removes leading and trailing spaces and reduces any run of internal spaces to a single space.
  5. Fill the formula down. Select the cell with the formula, hover over the small square at its bottom-right corner until the cursor becomes a black cross, then double-click or drag down to the last row of your data. Every row now has a cleaned version.
  6. Check a few results. Compare the original and cleaned cells side by side. If some cells still show extra gaps, they likely contain non-breaking spaces; continue to step 7. If everything looks right, skip to step 8.
  7. Handle non-breaking spaces. In a second helper column, enter =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) and fill it down. This replaces each non-breaking space with a normal space, then TRIM collapses the result. If you also need to remove line breaks, wrap the formula in SUBSTITUTE again with CHAR(10) replaced by a space.
  8. Convert formulas to values. Select the entire helper column, press Ctrl+C (Cmd+C on Mac), then right-click the same range and choose Paste Special > Values. This replaces the formulas with plain text so they no longer depend on the original cells.
  9. Replace the original data. Copy the cleaned values, select the first cell of your original column, and use Paste Special > Values again. Delete the helper columns when you are satisfied.
  10. Remove extra spaces between words only (optional). If you want to keep single spaces but delete all line breaks and tabs, use Find and Replace: select the range, press Ctrl+H (Cmd+H on Mac), type a space in Find what and leave Replace with empty to delete every space, or use the TRIM approach above to keep single spaces. Be careful: deleting all spaces will join words together.

Common Mistakes

  • Using Find and Replace to delete all spaces. This removes the spaces between words too, turning "New York" into "NewYork". Use TRIM when you want to keep single spaces.
  • Forgetting non-breaking spaces. TRIM alone does not remove CHAR(160). If TRIM seems to do nothing, the spaces are probably non-breaking; use the SUBSTITUTE method.
  • Pasting formulas instead of values. If you copy the helper column and paste normally over the original data, Excel adjusts cell references and you get wrong results or errors. Always use Paste Special > Values.
  • Working on the only copy. Without a backup, an accidental overwrite can destroy the original text. Keep a copy of the sheet before you start.
  • Assuming TRIM changes the original cell. TRIM returns a new value in the helper cell; the source cell stays unchanged until you paste values over it.

Tips

  • To see whether a cell contains non-breaking spaces, use =CODE(RIGHT(A2,1)) or =CODE(LEFT(A2,1)). A result of 160 confirms a non-breaking space; 32 is a normal space.
  • For a quick visual check, turn on formulas with Ctrl+` (Cmd+` on Mac) to see exactly what each cell contains.
  • If you clean data regularly, keep a template with the TRIM and SUBSTITUTE formulas ready in a helper column.
  • TRIM also removes the extra space that sometimes appears after text imported from web pages or CSV files.
  • When pasting values, choose Values only, not Values and Source Formatting, to avoid carrying over unwanted borders or fonts.

Troubleshooting

  • TRIM returns the same text. The spaces are likely non-breaking. Use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) and fill down.
  • Formula shows #NAME? or #VALUE!. Check that you typed the function names correctly and that the cell reference points to a text cell, not an error or blank cell that causes a type mismatch.
  • Cleaned column looks right but sorting still misbehaves. The original column may still contain the old values. Paste the cleaned values over the original column using Paste Special > Values, then delete the helper column.
  • Some rows did not fill. The fill handle may have stopped at a blank row. Select the full range manually and press Ctrl+D (Cmd+D on Mac) to fill down.
  • You accidentally overwrote data. Press Ctrl+Z (Cmd+Z on Mac) immediately to undo. If that is not enough, restore from the backup copy you made in step 1.

Frequently Asked Questions

Does TRIM remove all spaces?

No. TRIM removes leading and trailing spaces and reduces multiple internal spaces to one. It keeps single spaces between words and does not remove non-breaking spaces.

Why does TRIM not remove some spaces?

Those are usually non-breaking spaces (CHAR(160)), often introduced by web copy or CSV imports. Use SUBSTITUTE to replace CHAR(160) with a normal space before applying TRIM.

Can I remove extra spaces without a formula?

Yes. Select the range, open Find and Replace (Ctrl+H or Cmd+H), and replace double spaces with single spaces repeatedly until no double spaces remain. This is slower and does not remove leading or trailing spaces, so TRIM is more reliable.

Will TRIM work in Excel for the web?

Yes, TRIM and SUBSTITUTE are available in Excel for the web. The ribbon and Paste Special options are in slightly different places, but the formulas behave the same.

How do I remove spaces between words but keep single spaces?

Use TRIM. If you want to delete every space, use Find and Replace with a space in Find what and nothing in Replace with, but be aware this joins words together.

Does TRIM change numbers?

TRIM returns text. If your cells contain numbers formatted as text with extra spaces, TRIM cleans them but the result may still be text. Use Paste Special > Values and then convert to numbers if needed.