The TRIM function of Excel

Last Updated on 12/11/2024
Reading time: 2 minutes

The TRIM function is very useful for cleaning all the spaces before and after a string in Excel. It is one of the Top 10 Excel functions you must know.

This function only requires one argument: the text you want to clean 😉

=TRIM(text)

When importing data into Excel, using this function is highly recommended to clean extra spaces in your cells. This is essential for ensuring data accuracy, such as when sorting the data. Extra spaces at the beginning or end of strings can disrupt sorting, leading to incorrect results.

Sort with Spaces returns wrong result

Remove the spaces with the TRIM function

To clean up your data, use the formula: =TRIM(A2)

TRIM to remove the spaces in your cells

This function only removes spaces at the beginning or end of the text, not within it.

Transform the formulas into values

Once you use the TRIM function, it's important to convert these formulas into values. Leaving them as formulas means that the original cells still contain the unwanted spaces. To keep only the cleaned results, use Paste Special and select "Values."

Alternatively, use this trick with your mouse:

  1. Select your range of cells
  2. Right-click and drag the range to a new location
  3. Drag it back to the original location
  4. Release the right mouse button
  5. Select "Copy here as Values only"
Trick to Copy Paste value with the mouse

Leave a Reply

Your email address will not be published. Required fields are marked *

The TRIM function of Excel

Reading time: 2 minutes
Last Updated on 12/11/2024

The TRIM function is very useful for cleaning all the spaces before and after a string in Excel. It is one of the Top 10 Excel functions you must know.

This function only requires one argument: the text you want to clean 😉

=TRIM(text)

When importing data into Excel, using this function is highly recommended to clean extra spaces in your cells. This is essential for ensuring data accuracy, such as when sorting the data. Extra spaces at the beginning or end of strings can disrupt sorting, leading to incorrect results.

Sort with Spaces returns wrong result

Remove the spaces with the TRIM function

To clean up your data, use the formula: =TRIM(A2)

TRIM to remove the spaces in your cells

This function only removes spaces at the beginning or end of the text, not within it.

Transform the formulas into values

Once you use the TRIM function, it's important to convert these formulas into values. Leaving them as formulas means that the original cells still contain the unwanted spaces. To keep only the cleaned results, use Paste Special and select "Values."

Alternatively, use this trick with your mouse:

  1. Select your range of cells
  2. Right-click and drag the range to a new location
  3. Drag it back to the original location
  4. Release the right mouse button
  5. Select "Copy here as Values only"
Trick to Copy Paste value with the mouse

Leave a Reply

Your email address will not be published. Required fields are marked *