Remove Extra Spaces in Excel Using the TRIM Function

Use Excel's TRIM function to remove leading, trailing and repeated spaces so text is consistent and formulas/sorts work correctly.

What the video covers

Clean up text in worksheet cells by removing extra spaces (leading, trailing, and repeated spaces between words) using the TRIM function and replace original values if desired.

Watch the video on YouTube

Step-by-step instructions

  1. Select destination cell
    Click the cell where you want the cleaned text to appear (commonly next to the original data).
  2. Enter the TRIM formula
    Type =TRIM( and then select the cell that contains the text with extra spaces. Close the parentheses and press Enter. This removes leading, trailing, and extra spaces between words.
  3. Fill down as needed
    Copy the formula down the column (drag the fill handle or double-click it) to clean other rows.
  4. Replace originals (optional)
    If you want to overwrite the original text, copy the cleaned cells, then Paste Values over the original cells so only the cleaned text remains (not the formula).
  5. Handle non-standard spaces (if needed)
    If spaces persist, replace non-breaking spaces by wrapping SUBSTITUTE around the source: use SUBSTITUTE(cell, CHAR(160), " ") inside TRIM, e.g. =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).

Watch the video

Video thumbnail for Remove Extra Spaces in Excel Using the TRIM Function Play tutorial

Watch on YouTube

Why it matters

Extra spaces often come from imports or copy-paste and can break formulas, sorting, filtering, and lookups. TRIM standardizes spacing so data behaves as expected.

Check your result

After cleaning, verify by checking formulas, sorting results, or using exact-match functions (e.g., comparing cleaned cells to expected values). You can also visually inspect that leading/trailing spaces are gone and only single spaces remain between words.

Troubleshooting

If TRIM doesn't remove non-breaking spaces (common from web or PDFs), use a SUBSTITUTE step to replace that character (for example: SUBSTITUTE(cell, CHAR(160), " ")) and then apply TRIM. If you need to permanently replace originals, make sure to paste values over the original cells to remove formulas.