Purpose
Return value
Syntax
Using the TRIM function
The TRIM function strips extra spaces from text, leaving only a single space between words, and removing any leading or trailing space.
For example:
The TRIM function can be used together with the CLEAN function to remove extra space and strip out other non-printing characters:
TRIM often appears in other more advanced text formulas.
For example, the formula below will count the number of words in cell A1:
Because this formula depends on single spaces to get an accurate word count, TRIM is used to normalize space before the count is calculated.Full description here.
Notes
TRIM function examples
Split text with delimiter
Cell equals one of many things
Extract nth word from text string
Count total words in a cell
Join cells with comma
Extract multiple lines from a cell
Put names into proper case
Remove leading and trailing spaces from text
Normalize text
Extract word containing specific text
Get last word
Get last line in cell
LAMBDA count words
Sort comma separated values
Extract word that begins with specific character
TRIM function videos
How to clean text with CLEAN and TRIM
How to build all-in-one formulas
Related functions
CLEAN Function
The Excel CLEAN function takes a text string and returns text that has been “cleaned” of line breaks and other non-printable characters.