To see how TRIM works, open up the example workbook. On the first sheet, there’s a column of data—each cell contains at least one extra space.
It’s not always easy to tell, is it? Trailing spaces are especially hard to pick out.
But with TRIM, you don’t need to find those spaces. You can get rid of all of them at once.
To show you how effective TRIM is, we first need to do character counts on our current cells. Click into C2 and type the following formula:
When you hit Enter, you’ll see the number of characters in cell A2.
That’s not very informative on its own (though you might notice that “Jeff Davis” should only have ten characters).
Click into E2 and type this formula:
Then hit Enter.
Looks the same, right? Click into G2 and use the LEN function to get a character count of the new cell, though, and you’ll see that it isn’t:
The character count has decreased by two, because there were two trailing spaces on the text in the first cell.
It’s worth noting that you can also enter text directly into the trim function. Try this:
=TRIM(” too many spaces”)
As you can see, it immediately strips out the leading space and the extra spaces between “many” and “spaces.”
You probably won’t use text as an argument as you will a cell reference, but it’s good to know anyway.