Clean data is our birthright, but sometimes we are not able to access it.
Sometimes, we are not able to use our data the way we want. And one of the biggest reasons which make our data unable to use is…
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, you get those unwanted white spaces.
So, every time you work on your data you need to verify it first.
And in today’s post, I’m going to show you the exact 4 methods to remove all those unwanted and extra spaces.
Make sure to DOWNLOAD this SAMPLE FILE from here to follow along. Now let’s get started.
1. Remove Extra Spaces using TRIM Function [Trailing and Leading]
It happens sometimes that you get trailing and leading spaces in your data and it looks very nasty.
But we have a very simple and easy method to pull out this garbage and you need only one function to deal with it.
It removes all unwanted spaces from a text string except the spaces between two words, look at the below example.
As you can see, we have used TRIM to remove all the unwanted trailing and leading spaces from the cell.
There are 70 characters in the cell and when you have used TRIM, the characters count is decreased to 41, which means it has deleted the 29 spaces from the cell.
2. Combine Clean and Trim to Remove Extra Space from Line Break
There is also another possibility that you’ll get a line break in a text string.
In this situation, you need to use combine CLEAN and TRIM where the CLEAN function can remove all non-printing characters which include a line break as well.
How it works
First of all, CLEAN removes all non-printing characters from the text string, and then TRIM removes all the unwanted spaces from the text string other than the space between two words.
3. Using Clean, Trim, and Substitute to Remove All the Spaces from a Cell
Here we have another type of issue with these white spaces.
It happens sometimes that we want to remove all types of spaces from a cell. But cleaning and trimming are not able to remove all types 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.
Let me show you an example.
In the 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 a 10-digit mobile number from it.
how it works
SUBSTITUTE helps you to find a specific character or a set of characters from a text string and replace it with some other characters or a single character.
4. Use the Find and Replace Option to Remove All the Spaces
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 and REPLACE to replace white spaces from a cell, here are the steps:
- Select the cell or range of cells from which you want to remove white spaces.
- Use the shortcut key: Control + H to activate the find and replace option.
- In the “find what” input bar, insert a blank space using the space bar, and “Replace With” should remain blank.
- Click on the replace all button, you’ll receive a pop-up message about how many blank spaces are replaced.
Alert: Use this method only when you are confirmed to remove all types of spaces from selected cells.
Extra spaces are always irritating. But now you have 4 different methods to remove them and 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 and now you need to tell me one thing.
Do you know another way to deal with this problem?
Please share with me in the comment box, I’d love to hear from you and don’t forget to share this tip with your friends.