TRIM in Excel & Google Sheets
TRIM is used in 1 formula pattern in this library. Browse worked examples below, or use the generator to build a custom variation for your specific data.
When to use TRIM
- Clean up imported data where names, product codes, or addresses have inconsistent spacing that breaks VLOOKUP matches or pivot groupings.
Worked examples (1)
Common errors with TRIM
TRIM does not remove all spaces
TRIM removes standard spaces (ASCII 32) but not non-breaking spaces (ASCII 160) common in web-pasted data. Use SUBSTITUTE(TRIM(A2),CHAR(160),"") to handle both.
Numbers are affected unexpectedly
TRIM always returns a text string. If the source cell is a number with extra formatting, the result may be stored as text. Use VALUE(TRIM(A2)) to convert back to a number.
Frequently asked questions
How do I clean an entire column at once?
Add a helper column with =TRIM(A2), copy it down, copy the results, and paste-as-values over the original column. Then delete the helper column.
Need a custom variation?
Describe your specific TRIM problem and get a formula written for your exact data.
Open generator with TRIM