Excel Trim Function

Excel Trim function is very useful function that removes extra spaces from data. This formula removes all spaces from data except for single space between words. While validating data on the basis of, the trim function can give you valid length by removing spaces from beginning, spaces from end and extra spaces between words.

This can be useful for refining raw data received from any external application with irregular spacing.

The Microsoft Excel TRIM function returns a text value with the 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 a built-in function in Excel that is categorized as a String/Text Function.


  • Getting length of characters within a cell with cell reference:
  • =LEN(Cell Reference)
  • Getting length of a long string:
  • =LEN(“string”) (value needs to be kept within quotes)
  • Example

    Let's look at some Excel TRIM function examples and explore how to use the TRIM function as a worksheet function in Microsoft Excel: