Problem with Split and Symbol Code

pupsia

Board Regular
Joined
Dec 2, 2015
Messages
67
Hello everyone!

I`m trying to use a Split for find and replace invalid symbols from my data, as there are A LOT of symbols, doing it line by line seems not correct. I like to use Split for these types of things, but this time it is not working as Split adds "" to the values...

This would be and example of what i`m using:

BAD = Split("ChrW(&Hc0)|ChrW(&Hc1)|ChrW(&Hc2)|ChrW(&Hc3)|ChrW(&Hc4)|ChrW(&Hc5)|ChrW(&H100)", "|")
GOOD = Split("A|A|A|A|A|A|A", "|")

For k = 0 To UBound(BAD)
m = k
Selection.Replace What:=BAD(k), Replacement:=GOOD(m), LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next k


It doesn't work as the line after BAD GOOD is added looks like this:

Selection.Replace What:="ChrW(&Hc0)", Replacement:="A", LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False


And it needs to look like this to work:
Selection.Replace What:=ChrW(&Hc0), Replacement:="A", LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False


The example i gave is quite small, in my data i have about 150 minimum character codes, so adding line by line is not gonna work..

Any ideas how I could make it work? How not to add "" for example?

Any ideas would really help! Thank you!!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try doing it like
Code:
bad = Array(ChrW(&HC0), ChrW(&HC1))
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top