rodriar,
Thanks for the new character list.
Here is another macro for you to consider.
Sample raw data:
Excel 2007
| C |
---|
| |
a'a | |
b;b | |
c_c | |
d...d | |
e..e | |
f-f | |
g/g | |
h(h | |
i%i | |
j&j | |
k#k | |
m$m | |
n"n | |
n"n" | |
n"n"n | |
n"n"n" | |
"n"n"n" | |
o!o | |
p p | |
| |
<colgroup><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]9[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]13[/TD]
[TD="align: center"]14[/TD]
[TD="align: center"]15[/TD]
[TD="align: center"]16[/TD]
[TD="align: center"]17[/TD]
[TD="align: center"]18[/TD]
[TD="align: center"]19[/TD]
[TD="align: center"]20[/TD]
[TD="align: center"]21[/TD]
[TD="align: right"][/TD]
</tbody>
Sheet1
After the new macro:
Excel 2007
| C |
---|
| |
aa | |
bb | |
cc | |
dd | |
ee | |
ff | |
gg | |
hh | |
ii | |
jj | |
kk | |
mm | |
nn | |
nn | |
nnn | |
nnn | |
nnn | |
oo | |
pp | |
| |
<colgroup><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]9[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]13[/TD]
[TD="align: center"]14[/TD]
[TD="align: center"]15[/TD]
[TD="align: center"]16[/TD]
[TD="align: center"]17[/TD]
[TD="align: center"]18[/TD]
[TD="align: center"]19[/TD]
[TD="align: center"]20[/TD]
[TD="align: center"]21[/TD]
[TD="align: right"][/TD]
</tbody>
Sheet1
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
Code:
Sub RemoveSpecialCharactersV2()
' hiker95, 05/05/2015, ME852996
With Range(Range("C2"), Range("C" & Rows.Count).End(xlUp))
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",CHAR(34),""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""/"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","" "",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""'"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","";"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""_"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""..."",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","".."",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""-"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""("",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""%"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""&"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""#"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""$"",""""),"""")")
.Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ",""!"",""""),"""")")
End With
End Sub
Before you use the macro with
Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension
.xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
Then run the
RemoveSpecialCharactersV2 macro.