How to count characters in cell and then highlight.
Printable View
How to count characters in cell and then highlight.
Code:Option Explicit
Sub test()
Dim r As Range
Dim s As String
Dim k As Long
Dim n As Long
Set r = ActiveCell
r.Font.Color = vbBlack
s = r.Value
For k = 1 To Len(s)
If Mid(s, k, 1) Like "[!0-9]" Then
n = n + 1
r.Characters(k, 1).Font.Color = vbRed
End If
Next
MsgBox n
End Sub
マナ