Solved

Clean up data in Excel

Posted on 2011-03-11
5
270 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now