Clean Data With The TRIM Function In Excel

Gif showing how the TRIM Function worksThe TRIM Function in Excel is useful for removing extra spaces from text.

It’s especially handy when cleaning data imported from other sources, ensuring consistency and accuracy in your Excel work.

TRIM Function Details

TRIM Function Syntax


Available in: All versions of Microsoft Excel
User Level: Beginners
Inputs: “Text”: The text string from which you want to remove spaces.
Output: Text string without extra spaces. Data Type: Text
Wildcards: No
Case Sensitive: No

Where To Find The TRIM Function

To find the TRIM function, go to the top of the ribbon on your screen. Click Formulas > Text, and scroll down to the TRIM function button.

Not the function you are looking for? See our article on the Sum Function instead.

Using TRIM With Other Data Types

Table of using TRIM with other data types

Currency data:

Currency is treated as a number in Excel. Format currency as text to use TRIM effectively.

Simple Example

Imagine you have a list of names with inconsistent spacing.

Use TRIM to clean it up. In cell A2, type


This removes extra spaces from the name in A2.

Advanced Example

Let’s try combining TRIM with the SUBSTITUTE function.

Suppose you want to remove all spaces, not just extra ones. In cell B1, type

=SUBSTITUTE(TRIM(A2), " ", "")

This first trims A1, then removes all remaining spaces.

Combining functions together is a great way to increase the complexity of your work. Read this guide to the Average Function for more.

Troubleshooting & Errors

Lets take a look at the most common errors you will get when working with the TRIM function.

Error 1: #VALUE! Error

Cause: Non-text input.

Solution: Ensure the input is a text string.

Error 2: No Change in Data

Cause: No extra spaces in the input.

Solution: Check if the data already has the correct spacing.

Error codes can seem intimidating, but once you learn what they mean, they are a great tool for learning to trace errors in Excel.

What Is The TRIM Function Useful For?

The TRIM function is perfect for formatting big sets of data quickly. This makes it very useful in some keyareas.

1. Data Cleaning Removes unnecessary spaces, ensuring data consistency.
2. Data Validation Helps in verifying and correcting text data.
3. Preparing Data for Analysis Cleans data for accurate statistical analysis.

If you are looking to search for data instead, use the Find Function.

Similar Useful Functions

Other functions similar to the excel value function that are easy to use include:

  • TEXT: Converts numbers into text.
  • FORMAT: Returns a fully formatted string based on conditions.
  • TIME: Lets you create a time with specific components.


The TRIM function in Excel is a simple yet powerful tool for maintaining data integrity.

It’s essential for cleaning and preparing text data, making it a valuable skill for anyone using Excel.

What next? Take a look at our article on the Count Function here!


About Ben Richardson

Ben is a director of Acuity Training which he has been running for over 10 years.

He is a Natural Sciences graduate from the University of Cambridge and a qualified accountant with the ICAEW.

He previously worked as a venture capitalist and banker and so had extensive experience with Excel from building financial models before moving to learn SQL, Microsoft Power BI and other technologies more recently.