Remove extra spaces from text, leaving single spaces between words.
Syntax
TRIM(text)Arguments
textrequired
The text to clean.
TRIM strips leading, trailing, and duplicate spaces — a common cause of failed lookups and mismatched joins. Run it on imported or copied data before matching with VLOOKUP or XLOOKUP.
=TRIM(" Jane Doe ")→Jane DoeCollapses the extra spaces to single spaces.
Wrap the messy text
Apply TRIM to the imported column.
Paste back as values
Copy the cleaned result and paste as values to replace the originals.
Invisible trailing spaces make two values look equal but not match. TRIM removes them so the lookup keys align.