PDA

View Full Version : [SOLVED:] Stuck with replacing character



JKwan
10-15-2021, 11:06 AM
I am trying to replace a stubborn character. It looks like a dash (-), but it is not a "real" dash that is on the keyboard. I am attaching a workbook so you know what I mean. I tried to just replace it, obviously that failed. I then try to get the ascii code (45), but that is a real dash, FAILED. I then copied the character and put into my VBA editor program, did not work, because it is trying to look for the real dash.... So, if I copy that character and put into the FIND REPLACE panel, works like a charm. If I paste that character into Notepad++, I get a character of a "box", so I paste this box into VBA editor, it turns into a dash, of course this fails. So, how do I get this character replace with a real dash? Thank you everyone.

Paul_Hossler
10-15-2021, 11:38 AM
That's a Unicode hyphen, probably caused by copy/pasting from another system




Sub FixDash()


Call Selection.Replace(ChrW(&H2010), "-", xlPart)


End Sub

JKwan
10-15-2021, 11:43 AM
Paul:
Thank you again. That is working great.