Syntax
| Parameter | Description |
|---|---|
| text | Parameter of the TRIM function. |
Examples
Clean up messy imported text
=TRIM(A2)
Fix VLOOKUP failures from spaces
=VLOOKUP(TRIM(A2), D:E, 2, FALSE)
Clean and compare
=EXACT(TRIM(A2), TRIM(B2))
Common Errors
The cell contains an error value. TRIM only works on text strings, not error values like #N/A or #REF!.
Tips
Web data often contains non-breaking spaces (char 160). Use SUBSTITUTE(A1, CHAR(160), " ") before TRIM.
Apply TRIM to an entire column of imported data before doing lookups or comparisons — hidden spaces are the #1 cause of failed VLOOKUPs.
=TRIM(CLEAN(A1)) removes both non-printable characters (CLEAN) and extra spaces (TRIM) for thorough data cleaning.
Try TRIM in Viztab
Import your data and use TRIM with 370+ other formulas. No signup required.
Open Viztab