Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Clean up data in Excel

Posted on 2011-03-11
5
Medium Priority
?
278 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

916 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