TRIM Generator
Remove leading, trailing, and doubled-up spaces from text in a cell.
TRIM
Remove leading, trailing, and doubled-up spaces from text in a cell.
The cell whose spacing you want cleaned up. Literal text needs quotes, for example " hello ".
=TRIM(A2)Worked Example
A2 contains the imported text " Ada Lovelace " with padding at both ends and three spaces in the middle.
=TRIM(A2)Returns: Returns Ada Lovelace: the outer spaces are gone and the internal run is reduced to a single space.
Checks Before You Paste
- •TRIM only collapses runs of spaces down to one and clears the ends. It never removes all internal spaces, so use =SUBSTITUTE(A2, " ", "") if you want none at all.
- •Text copied from web pages or PDFs often contains a non-breaking space, CHAR(160), which is not the plain CHAR(32) space TRIM looks for, so TRIM leaves it in place. Clean it first: =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).
- •TRIM always returns text, so a trimmed number stays left-aligned and is skipped by SUM, COUNT, and most lookups. Wrap it as =VALUE(TRIM(A2)) when the cell should behave as a number.