Removing Extra Spaces and Special Characters with TRIM and CLEAN

Tap a step below to see it explained in order.

  1. Check for unwanted spaces

    Look for invisible leading or trailing spaces, especially in data copied in from another source.

  2. Remove spaces with TRIM

    A formula like =TRIM(A1) removes all leading and trailing spaces and collapses multiple spaces between words down to just one.

  3. Remove special characters with CLEAN

    A formula like =CLEAN(A1) strips out non-printing characters that often sneak in when copying from another program.

  4. Use both functions together

    Nesting them as =TRIM(CLEAN(A1)) cleans up spaces and special characters in a single step.

  5. Why this is useful

    When two values look identical but a lookup or comparison formula keeps failing, an invisible space or special character is usually the culprit.

When matching values just won't match

One of the most frustrating Excel mysteries is a VLOOKUP or equality check that fails even though both values look completely identical on screen. Nine times out of ten, the cause is a stray space or an invisible non-printing character left over from a copy-paste, and TRIM and CLEAN are built specifically to fix exactly that.

What each function actually does

TRIM only touches whitespace β€” it removes leading and trailing spaces and reduces any run of multiple spaces between words down to a single space, but it won't touch anything else. CLEAN targets non-printing control characters instead, such as ones left behind by data exported from another system, including line breaks. Because they solve different problems, nesting them together handles both space and character issues in one pass.

Frequently Asked Questions

Does TRIM remove all the spaces between words too?

No β€” it leaves a single space between words intact and only removes duplicate spaces along with any leading or trailing spaces around the text.

Does CLEAN remove line breaks too?

Yes. CLEAN removes most non-printing control characters, and a line break character falls into that category, so it gets removed as well.