Excellency

View Original

The TRIM function

The TRIM function is a text function which removes any additional spaces found within a string of text, leaving only one space between each word. It will also remove leading or trailing spaces.

This is the format of the TRIM function:

=TRIM(STRING)

Here is an example of the TRIM function:

=TRIM(“ Hi how are you? “) = “Hi how are you?” 

TRIM function removing the leading and trailing spaces from the original text string

This function is valuable when you are dealing with text which has been imported from another source such as a website or PDF document, and it needs to be cleaned of any formatting abnormalities. Pairing TRIM with the CLEAN function leads to much easier and faster text processing.

An example of a functional implementation of this would be if you were pulling tabular results from a website which includes text descriptions in it, and upon importing them into Excel you notice that the formatting did not transfer well. Additional spaces, line breaks, or other errors are showing. Your first step would be to TRIM unnecessary spaces out of the text.

=TRIM(CELL REFERENCE)