VBAでセル内のすべての指定文字列の色を変更する
VBAでセル内に複数指定文字列がある場合に、のべての指定文字列の色を変える。
Sub ColorChange()
Const strTarget As String = "指定文字列"
Dim c As Range, i As Integer, j As Integer
Dim strCnt As Integer
j = Len(strTarget)
For Each c In Selection
i = 1
strCnt = Len(c)
If strCnt > 0 Then
Do
i = InStrRev(c, strTarget, strCnt)
If i > 0 Then
c.Characters(i, j).Font.ColorIndex = 3
strCnt = i - 1
Else
Exit Do
End If
Loop While strCnt <> 0
End If
Next
End Sub
たぶん、もっと良い書き方があるはず。