Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Clean up data in Excel

Posted on 2011-03-11
5
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

722 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