What it does
TRIM removes extra spaces and CLEAN removes many non-printing characters.
Syntax or pattern
=TRIM(text) / =CLEAN(text)5 practical examples
Remove extra spaces
Clean a name imported with double spaces.
=TRIM(A2)TRIM keeps single spaces between words.
Clean imported text
Remove non-printing characters.
=CLEAN(A2)Useful after copying from systems or PDFs.
Use both together
Clean messy imported text.
=TRIM(CLEAN(A2))A strong first cleanup step.
Fix lookup values
Clean a lookup value before matching.
=XLOOKUP(TRIM(A2),Products[Code],Products[Name])Hidden spaces often break lookups.
Clean full column with table reference
Apply cleanup to a table column.
=TRIM(CLEAN([@Name]))Works well in helper columns.
Common mistakes to avoid
- Not handling missing delimiters.
- Forgetting that some text functions return text, not numbers.
- Using fixed positions when the text layout is not consistent.
Related Excel examples
FAQ
Can text formulas work with Excel Tables?
Yes. Table references can make text-cleaning formulas easier to understand.