How to Use the TRIM Function in Microsoft Excel


Excel Logo on a gray background

When you duplicate textual content into Microsoft Excel, it can at times come with figures you’d favor to see eradicated, this sort of as avoidable areas. Relatively than get rid of these manually, you can use the TRIM perform to do it for you.

What Is the TRIM Function?

TRIM is a extremely easy Microsoft Excel functionality that eliminates any added areas from a unique text string or from a mobile containing text, leaving only a single room involving phrases.

For occasion, let’s suppose that a mobile in Excel has a textual content string like this:

This is a text string.

This string alone contains a one space among each individual word. However, if there ended up more areas in your text string right before the to start with phrase (eg. ”    This is a textual content string.”) or if it had multiple areas among phrases (eg. “This   is   a    text    string.”), then you could use the TRIM operate to eliminate these for you.

When you could do this manually, TRIM enables you to rapidly remove avoidable spaces from huge sets of data, conserving you time in the process.

There is one limitation, nonetheless. TRIM removes the ASCII house character (decimal benefit 32) from textual content strings, which is the typical space character used in most textual content.

The exception to this is for textual content on web webpages, the place the Unicode non-breaking room character (decimal price 160) is often employed for areas. TRIM won’t take away this, so if this character exists in your text, you will have to have to take out it manually.

Similar: What Are Character Encodings Like ANSI and Unicode, and How Do They Vary?

How to Use the TRIM Functionality in Microsoft Excel

To help you have an understanding of how to use the TRIM functionality in Excel, we’ll investigate the two major techniques for making use of it in a new method using sample knowledge.

If you’re making a method using TRIM, it has only a one argument—the textual content itself. This can be textual content you insert into the components specifically or a mobile reference to a mobile that contains your text.

For example, the following formulation makes use of TRIM to remove unneeded area characters from cell A2. To use this components by yourself, change the mobile reference “A2” with your own.

=TRIM(A2)

To remove additional spaces from a textual content string directly, you could use the following system, replacing the instance string with your very own textual content.

=TRIM(" This text string includes needless spaces")

As beforehand mentioned, TRIM is only intended to take out additional ASCII house people (decimal worth 32) from textual content strings. If you’re nevertheless observing avoidable spaces, this is likely brought about by a non-breaking house character (Unicode decimal price 160) in your text.

TRIM doesn’t help these, so you are going to have to have to manually examine and remove these figures from your textual content if you’d want to use it.

Exit mobile version