What TRIM does
TRIM cleans spacing problems in text. It removes leading spaces, trailing spaces, and repeated spaces between words, leaving only single internal spaces.
That is especially helpful before lookups, comparisons, imports, and deduplication.
Practical examples
Clean imported names or codes
=TRIM(A2)
Use this when a pasted or imported field contains spaces that are not visible at first glance.
Stabilize lookups
=VLOOKUP(TRIM(E2),$A$2:$C$20,3,FALSE)
Wrapping the lookup value with TRIM can prevent failed matches caused by stray spaces.
Common mistakes and notes
TRIM does not fix every invisible character
It handles regular spaces well, but some imported data contains nonbreaking spaces or other characters that may need a more advanced cleanup step.
Clean both sides when necessary
If a lookup still fails after trimming the lookup value, the source column may need cleanup too.