TRIM Function In Excel
This Excel Tutorial demonstrates how to use the Excel TRIM Function in Excel to remove all extra spaces from text, with formula examples.
TRIM Function Description:
The TRIM Function Removes all extra spaces from a text string. Retains single spaces in between words.
|Remove Leading Spaces||=TRIM(C5)||<|
|Remove Extra Spaces||=TRIM(C6)||extra spaces|
|Remove Trailing Spaces||=TRIM(C7)||trailing spaces >>|
Syntax and Arguments:
The Syntax for the TRIM Formula is:
Function Arguments ( Inputs ):
text – A string of text.
When working with text, it’s always a good idea to use the TRIM Function to clean the text. Extra spaces can cause unwanted errors when working with functions such as VLOOKUP and MATCH.
You can use the EXACT Function to test if two strings of test are equal. Keep in mind, the EXACT, SUBSTITUTE, and FIND functions are case-sensitive, so it’s also a good idea to use the UPPER, LOWER, or PROPER functions to put all the text in a consistent case.
TRIM Examples in VBA
You can also use the TRIM function in VBA. Type:
For the function arguments (text, etc.), you can either enter them directly into the function, or define variables to use instead.
Return to the List of all Functions in Excel
How to use the TRIM Function in Excel:
To use the AND Excel Worksheet Function, type the following into a cell:
After entering it in the cell, notice how the AND formula inputs appear below the cell:
You will need to enter these inputs into the function. The function inputs are covered in more detail in the next section. However, if you ever need more help with the function, after typing “=TRIM(” into a cell, without leaving the cell, use the shortcut CTRL + A (A for Arguments) to open the “Insert Function Dialog Box” for detailed instructions:
For more information about the TRIM Formula visit the