Excel之批量改变特定字体颜色(转载)

改变单元格内部分特定字符的颜色,如果批量操作,需要用宏处理,

如下例,将范围内 所有字母A 变成红色

操作步骤:
右键点击工作表标签,查看代码,如下代码复制进去
Private Sub CommandButton1_Click()
Cells.Font.ColorIndex = 1
End Sub

Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range, i As Integer
For Each rng In Selection
i = 1
Do While InStr(i, rng, "A") > 0
rng.Characters(InStr(i, rng, "A"), 1).Font.ColorIndex = 3
i = InStr(i, rng, "A") + 1
Loop
Next
End Sub

 

 

posted @ 2018-10-10 12:10  意如柳  阅读(4183)  评论(0编辑  收藏  举报