Delete the "Exit For"
Sub SplChars()
Dim sCharOK As String, s As String
Dim r As Range, rc As Range
Dim j As Long
sCharOK = "1234567890-=~!@#$%^&*()_+qwertyuiop[]\asdfghjkl;'zxcvbnm, ./QWERTYUIOP{}|ASDFGHJKL:ZXCVBNM<>?"""
Set r = Worksheets("Sheet1").UsedRange.SpecialCells(xlCellTypeConstants, xlTextValues)
' loop through all the cells with text constant values and paints in yellow the ones with characters not in sCharOK
For Each rc In r
s = rc.Value
For j = 1 To Len(s)
If InStr(sCharOK, Mid(s, j, 1)) = 0 Then
rc.Characters(j, 1).Font.Bold = True
End If
Next j
Next rc
End Sub
Alternatively you coud:
For Each rc In r
s = rc.Value
For j = 1 To Len(s)
If InStr(sCharOK, Mid(s, j, 1)) = 0 Then
With rc.Characters(j, 1).Font
.Bold = True
.Size = 16
.Color = rgbCadetBlue
End With
End If
Next j
Next rc
and so on...
Please mark SOLVED and Add Reputation if my answer pleases you. Thank you.
Bookmarks