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

x
?
Solved

Excel 2010 VBA - How to delete excess spaces inside of a cell

Posted on 2013-05-13
2
Medium Priority
?
320 Views
Last Modified: 2013-05-13
I have a group of cells (A1:A300) that contain names.  However, immediately preceeding the names are a bunch of spaces.  I don't know how they got in there but I would like to have some way of deleting the spaces and retaining the names.
How can I do this using VBA?
Or maybe I don't need vba?
0
Comment
Question by:brothertruffle880
[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
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 39162995
Try using a formula like:
=TRIM(SUBSTITUTE(A1,CHAR(160)," "))

The ASCII 160 non-breaking space is frequently found in data imported from elsewhere and cannot be removed by TRIM. That's why the SUBSTITUTE function is wrapped inside the formula--to convert those ASCII 160 non-breaking spaces to regular ASCII 32 spaces.

TRIM removes all leading and trailing ASCII 32 spaces, and all but one space between words.
0
 

Author Comment

by:brothertruffle880
ID: 39163354
Perfect.  Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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…

704 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