Author: Oscar Cronquist Article last updated on June 20, 2018

The picture above shows you values that have multiple leading and trailing blanks, sometimes also between words.

The TRIM function deletes all blanks or space characters except single blanks between words in a cell value.

Excel Function Syntax

TRIM(text)

Argument

text The string or cell value you want to delete blanks from.

Comments

The TRIM function removes the space character from a cell value, however, there is another space character commonly used in HTML pages that are not removed by this function.

To remove that space character you need to use the SUBSTITUTE function with the TRIM function. Formula in cell C3:

=TRIM(SUBSTITUTE(B3, CHAR(160), " "))

CHAR(160) returns the other space character that TRIM can't delete. The SUBSTITUTE function then replaces the HTML space character with a regular space character.