TRIM function

TRIM() function

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Remove irregular spacing from either end of or within a text string.

TRIM(text)


Remove irregular spacing from either end of or within a text string using either defined values (e.g. "string") or cell references (e.g. C3).

TRIM syntax requires just the defined value or cell reference to be trimmed.


TRIM with a text string.

In the examples below, the TRIM function is used to remove irregular spacing before, within or after the defined text string " North America " or cell reference to "Ottawa ".

Use the TRIM function to remove irregular spacing from either end of or within a text string.

Use the Excel function TRIM to remove irregular spacing from either end of or within a text string.

Syntax

The TRIM function consists of 1 argument:

  1. text. Required. The string from which to trim the irregular spaces.

Try it now!

Enter your formula into the grey cells.


Scope

TRIM() can be applied to cell references, text or numbers.

  • Cell reference:
  =TRIM(C3)
  • Text:
  =TRIM(" South America ") || returns South America.
  • Number:
  =TRIM( 123456.78 )*1 || returns the number 123456.78.

Caveats

  • The TRIM() function was designed to trim a 7-bit ASCII space character (value 32) from a text string.
  • TRIM() will not remove nonbreaking space characters from the Unicode character set (value 160) such as   used in HTML.

Related Functions

  • The CLEAN() function can help remove the first 32 nonprinting characters in the 7-bit ASCII code (values 0 through 31) from text.
  • The SUBSTITUTE() function can be used to replace higher value Unicode characters (values 127, 129, 141, 143, 157 and 160) with the 7-bit ASCII characters for which the TRIM() function was designed.

Functions Category

 

Register (for free!) or Login to access bonus materials

About xlsnippets

Learn how to master functions, charts, pivot tables and more using Excel for Microsoft Office 365. Simple instructions and embedded spreadsheets help you practise the basics.

Latest Updates

26 March 2022
26 March 2022
26 March 2022
25 March 2022
22 March 2022

Coming soon

xlsnippets.com is currently in beta version. More functions and bonus content for registered users will be added weekly. Detailed training courses with additional downloadable resources are also on the horizon!