Excel vba删除“?”(问号)和“*”(星号)
我试图从Excel表格中replace所有特殊字符
但是? (问号)和*(星)给空白单元格
现在我正在使用这个代码
Selection.Replace What:="!", Replacement:=" " Selection.Replace What:="@", Replacement:=" " Selection.Replace What:="#", Replacement:=" "
….等等
问号和星号在查找和replace函数中被称为通配符,这意味着它们已经意味着除string值之外的其他东西。 为了解决这个问题,你需要在它们前面加一个波浪号(〜)。
尝试:
Selection.Replace What:="~?", Replacement:=" " Selection.Replace What:="~*", Replacement:=" "
这里有一个有用的链接: https : //support.microsoft.com/en-gb/kb/214138
使用正则expression式: http : //analystcave.com/excel-regex-tutorial/
无论如何,这是一个更灵活的方式进行文本匹配。