How to Trim Whitespaces in Google Sheets
In this article, you will learn how to remove extra spaces with the TRIM functionin Google Sheets. The function is beneficial when you need to clean up a data set as a preparation to use other functions such as COUNTIF or SUMIF.
How to use the TRIM formula in Google Sheets
- Type “=TRIM(” or go to “Insert” → “Function” → “Text” → “TRIM”.
- Select a text from which you remove extra whitespaces
The generic syntax is as follows:
Text: You can refer to a cell containing a text you want to trim or type in the text directly.
The TRIM function can delete whitespaces in front of or at the end of a text string. It also removes the extra spaces between words to leave a single space.
Assume you are a marketing manager and looking at customer survey data. As each form was filled by an individual customer, you see typos, especially extraneous spaces in the customer’s name section. So, you want to clean them up by using the TRIM function.
Another way to trim whitespaces
If the number of texts you will clean up is small, you can do it manually. However, if the number is large, instead of using the TRIM function, you can take the following approach: go to the “Data” tab → “Data cleanup” → “Trim whitespaces”.
The “Trim whitespaces” effect is the same as the TRIM function; it removes any spaces ahead of or at the end of text strings or takes extra whitespaces between two words to leave only single whitespace.