Sub 選択範囲の指定の文字を赤く()
Dim Target As String
Dim Rng As Object
'' 赤くしたい文字をユーザーに入力してもらう
Target = Application.InputBox("変更する文字を入力")
'' 何も入力されなければ終了する
If Target = "" Then
Exit Sub
End If
'' 選択したセルをすべて処理する
For Each Rng In Selection
Dim Pos As Long
'' セルに含まれる文字を全て処理する
Pos = InStr(1, Rng.Value, Target)
Do Until Pos = 0
'' 部分的に色を3(赤)に設定
Rng.Characters(Pos, Len(Target)).Font.ColorIndex = 3
Pos = InStr(Pos + Len(Target), Rng, Target)
Loop
Next
End Sub
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme