VBA Question

I got help in getting a data cleaning script written to help remove unwanted spaces and characters in my source data.  It works pretty well but I have noticed that it has missed catching some blank spaces. Any idea on why?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

They might be 'non-breaking spaces'. Just taking a look now at your sample file.
Please identify an example cell that has the problem.

To remove non-breaking spaces you could modify the "=TRIM" line in your CleanData macro
WS.Range("ZZ1:ZZ" & MaxRow).Formula = "=TRIM(SUBSTITUTE(" & Left(rCol.Address, InStr(1, rCol.Address, ":") - 1) & "1,CHAR(160),CHAR(32)))"

Open in new window

Martin LissOlder than dirtCommented:
They may be unprintable characters. To determine what the character is, go to Visual Basic (Alt+f11) and in the Immediate Window (ctrl+g) type


where A1 is the cell with the "blank", and 4 is the text position of the character, and press return. To remove the character you can do something like the following in your macro or outside your macro which in this case would remove the character with an Ascii value of 14.

Range("A1") = Replace(Range("A1"),Asc(14),"")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rrave26Author Commented:
I will try that today Martin, and get back to you with the results.
Rrave26Author Commented:
I agree. Martin.  Thanks for the help.
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.