|
楼主 |
发表于 2016-10-31 20:54
|
显示全部楼层
已有基础代码
已有基础代码
Sub excelvba》所有含单元格中重复出现关键词》字体高亮》【爱疯答案】》()
Application.EnableEvents = True '代码结束前,专治死机
t = Timer
Dim 关键词变量, reg, match, matchs, x
Set reg = CreateObject("VBScript.RegExp")
reg.Global = True
关键词变量 = "计算公式"
'自定义
For Each x In ActiveSheet.UsedRange
If InStr(x, 关键词变量) Then
x.Font.ColorIndex = xlAutomatic
reg.Pattern = 关键词变量
Set matchs = reg.Execute(x)
For Each match In matchs
x.Characters(Start:=match.FirstIndex + 1, Length:=match.Length).Font.Color = -65281
x.Characters(Start:=match.FirstIndex + 1, Length:=match.Length).Font.Bold = True
Next
End If
Next
MsgBox "结束!-用时=" & Timer - t & "秒"
Application.EnableEvents = True '代码结束前,专治死机
End Sub |
|