Solved

Clean up data in Excel

Posted on 2011-03-11
5
271 Views
Last Modified: 2012-05-11
I have an Excel file I need to clean up some data

This is what I have and need to know how to remove unnecessary black spaces.

Suite 22      - 222 Anywhere Street

I don not want to remove the space in Suite 22 and so on. The field size are all different and spaces. I have attached an excel sample.

Expert-Exchange-Sample.xlsx

Can someone help me with this?

0
Comment
Question by:Gerhardpet
5 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35110255
Simple way:
Press Ctrl+H to bring up the replace dialog.
Enter two spaces in the Find box and one in the Replace box. Press Replace All, then OK the message that comes up. Repeat the last step until it says no data found. :)
0
 
LVL 4

Expert Comment

by:knarf75
ID: 35110397
I modified some code for you i found here: http://excel.tips.net/Pages/T003037_Removing_Spaces.html

Sub NoSpaces()
    Dim c As Range

    For Each c In Selection.Cells
     Do
        c = Replace(c, "  ", " ")
     Loop While InStr (1,c.Text,"  ")
    Next
End Sub

Select the cells you want to modify, and then run the macro. It examines each cell in the selected range, removing any spaces in that range. The result is then placed back in the same cell.
0
 
LVL 4

Expert Comment

by:knarf75
ID: 35110433

Forgot something:

You have to make a macro first that is called NoSpaces and paste the code in I provide above.

0
 

Expert Comment

by:--TripWire--
ID: 35110577
Do you know C/C++?
You can save the file as a comma-delimited csv file and write some code that would clean up the spaces and save it back as a txt file that can be re-opened as a csv.
But that may be a bit longer than what you're looking to do.
0
 
LVL 1

Author Comment

by:Gerhardpet
ID: 35112153
Thank you rorya! That was very simple indeed...
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question