How TRIM works
Syntax
=TRIM(text)text- The cell or text to clean.
Example
A VLOOKUP returns #N/A because product codes in the export have a trailing space.
=VLOOKUP(TRIM(F2), A:C, 3, FALSE)Trimming the search value makes "PRD-101 " match "PRD-101".
Common mistakes
- Non-breaking spaces from web pages, which TRIM doesn't remove. Use =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).
- Leaving the TRIM formulas in place. Copy the cleaned column and paste as values, then delete the original.
Questions people ask
How do I remove all spaces, not just extra ones?
Use SUBSTITUTE: =SUBSTITUTE(A2, " ", "").
Practice it above: type the formula in the formula bar and press Enter to check.