Excel vba to remove "?" (question mark) and "*" (star)

excel, vba

Solution

Question marks and asterisks are known as wildcards in find and replace functions, this means they already mean something other than their string values. In order to get round this you need to precede them with a tilde (~).

Try:

Selection.Replace What:="~?", Replacement:=" "
Selection.Replace What:="~*", Replacement:=" "

Here's a helpful link: https://support.microsoft.com/en-gb/kb/214138

Problem

I am trying to replace all special characters in an Excel sheet. But `?` (question mark) and `*` (asterisk) are resulting in a blank cell The code I'm using: ``` Selection.Replace What:="!", Replacement:=" " Selection.Replace What:="@", Replacement:=" " Selection.Replace What:="#", Replacement:=" " ``` .... so on

Original source