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?
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),"")
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

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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.