您可以将正则表达式用于此任务。
否定的字符类是一个有用的正则表达式构造:您可以在其中使用[^...]并插入不想匹配的范围。因此,要匹配ASCII字母,数字和连字符以外的其他字符,请使用[^a-zA-Z0-9-]。
并像这样使用
Dim strPattern As String: strPattern = "[^a-z0-9-]"
Dim regEx As Object
Set regEx = CreateObject("VBScript.RegExp")
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = strPattern
For Each cell In ActiveSheet.Range("C:C") ' Define your own range here
If strPattern <> "" Then ' If the cell is not empty
If regEx.Test(cell.Value) Then ' Check if there is a match
cell.Interior.ColorIndex = 6 ' If yes, change the background color
End If
End If
Next
Run Code Online (Sandbox Code Playgroud)