Excel Productivity Guide
Useful Excel Tips | Keyboard Shortcuts | VBA Codes
Download this Free E-Book to take your excel skills to a whole next level using some smart Excel tactics.
Worth $20, Absolutely Free
A clean data is our birthright. But sometimes, we are not able to access it. Sometimes, we are not able to use our data as the way we want.
And, the of the one biggest reasons which make our data unable to use is extra spaces in a cell. So, if you want to use it we need to remove them all.
When you think about this, most of the time when you get data from ERP systems or you have some formulas which not written properly, we got those unwanted white spaces.
Even, every time when you work on your data you need to verify it first.
So today, in this post, I’d like to share with you 4 different methods to remove all those unwanted and extra spaces.
And, you will also learn that why all these methods are unique and usable in different situations. So let’s get started and please download this sample file to follow along.
It happens sometimes that you get trailing and leading spaces in your data and it looks very nasty. But we have a very simple & easy method to pull out this garbage from our data.
And, we need only one function to deal with it. TRIM FUNCTION.
TRIM can remove all unwanted spaces from a text string except the spaces between two words.
In above example, we have used TRIM Function to remove all the unwanted trailing and leading spaces from the cell.
We have total 70 characters in the cell in which we have unwanted spaces & when I have used TRIM characters count is decreased to 41. That means it has deleted the 29 spaces from the cell.
Now, there is also an another possibility that you’ll get a line break in your text string.
In this situation, you need to use CLEAN function with TRIM. The clean function can remove all non-printing character which includes a line break as well.
In above example, we have used a formula by combining trim and clean to remove line break.
First of all, the clean function will remove all non-printing characters from a text string and then trim function will remove all unwanted spaces from text string other than space between two words.
Here we have an another type of issue with these white spaces.
It happens sometimes that we want to remove all type of spaces from a cell. But clean and trim both are not able to remove all type of spaces.
For example, if you have a non-breaking space in a cell, you will not able to deal with it using both of these functions. And for this problem, you need to combine CLEAN and TRIM with SUBSTITUTE function.
Let me show you an example.
In below example, we have a list of mobile numbers in a worksheet. And, these numbers are surrounded by some unwanted white spaces. we only need 10 digit mobile number from it.
But, by using both trim and clean we are not able to do that. That’s why we have to use substitute function.
Substitute function can help you to find a specific character or a set of characters from a text string & replace with some other characters or a single character.
Wait a minute I have another option to solve the above-mentioned problem. And, you don’t have to use a formula for that. You can use find & replace option to replace white spaces from a cell.
Here are the steps.
Important Note: Use this method only in that situation when you are confirmed to remove all type of spaces from selected cells.
Extra spaces are always irritating. But now, you have 4 different methods to remove them. You can choose any of these methods which you think is perfect for you.
I hope this will help you to play well with your data.
Now tell me one thing. Do you know any other problem related to unwanted spaces in excel which I am now covering here? Or, you have any other way to deal with these problems.
Please share with me in the comment box. I would love to hear from you.