How to Use the TRIM Function in Microsoft Excel?

The TRIM function is classified under Excel text functions. TRIM helps to remove the extra spaces in the data, thus cleaning up the worksheet cells. In financial analysis, the TRIM function can be helpful for removing trailing spaces from data imported from other applications. TRIM removes extra spaces from the text. Therefore, only single spaces are left between words, and no spaces are left at the beginning or end of the text. It is beneficial when cleaning text from other applications or environments. TRIM only removes the ASCII space (32) from the text. Unicode text often contains a nonbreaking space (160) displayed on web pages as an HTML entity. It is not removed with TRIM.

The Microsoft Excel TRIM function returns a text value with leading and trailing spaces removed. You can also use the TRIM function to remove unnecessary spaces between words in a string. The TRIM function is an Excel built-in function classified as a string/text function. It can be used as a spreadsheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the TRIM function can be entered as part of a formula in a worksheet cell. As a VBA function, you can use this function in macro code entered through the Microsoft Visual Basic Editor.

What is the TRIM Function?

Microsoft Excel is an inbuilt function that lets you remove any extra spaces from a specific text string or a cell containing text, leaving only a single space between words.

How to use the TRIM Function in Microsoft Excel?

For instance, we have data in cell A1 will multiple spaces; we want to remove that unnecessary spaces and want purified data in cell B1. Click on cell B1 and write “=TRIM(A1)”. Then, press Enter from the keyboard to produce the filtered data.

The result will be like the below screenshot:-

Alternatively, to remove extra spaces from a text string directly, you can use the following formula:-

=TRIM("Unpurified Data")

So, replace the ‘Unpurified Data‘ and put your sentence or paragraph to purify it.

Next, press Enter from the keyboard to get the data without unnecessary spaces.

Here, in addition to extra spaces, if your data contains line breaks and other non-printing characters, you can use the TRIM function in combination with CLEAN to delete the first 32 non-printing characters in the 7-bit ASCII code system.

For example, if you want to remove spaces, line breaks, and other unwanted characters from cell A1, use this formula:

=TRIM(CLEAN(A1))

Finally, press Enter from the keyboard to get the result.

That’s it for the article.

I hope this risewindows post will be informative & valuable to you.

Good luck & keep reading, guys.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: