The TRIM function in Google Sheets is designed to streamline your data by removing any extraneous spaces from the beginning and end of text strings. This simple yet effective function is particularly useful for cleaning up user input or imported data, ensuring that your entries are consistent and free from unnecessary whitespace.
Syntax
TRIM(text)
- text: The string from which leading and trailing spaces will be removed.
Example #1
=TRIM(" Hello, World! ")
This function call removes the leading and trailing spaces from the string, resulting in “Hello, World!”.
Example #2
=TRIM(" Google Sheets ")
The function cleans the input, producing the result “Google Sheets” without additional spaces.
Example #3
=TRIM(" Data Entry ")
By applying this function, the output will be “Data Entry” free of excess whitespace at both ends.
Error handling
- VALUE! : This error occurs when the input provided is not recognizable as a text string.
- REF! : This happens if the reference used in the function is invalid or has been deleted.