|
Option Explicit
Sub TEST()
Dim ar, i&, Matches As Object, aMatch, Rng As Range, strPat$
Application.ScreenUpdating = False
ar = [U6].CurrentRegion.Value
For i = 2 To UBound(ar)
strPat = strPat & "|" & ar(i, 1) & ar(i, 2)
Next i
Set Rng = [A3].CurrentRegion
With Rng
ar = Rng.Value
.Font.Color = 0
End With
With CreateObject("Vbscript.RegExp")
.Global = True
.Pattern = Mid(strPat, 2)
For i = 2 To UBound(ar)
Set Matches = .Execute(ar(i, 14))
With Rng
For Each aMatch In Matches
.Cells(i, 14).Characters(aMatch.firstindex + 1, Len(aMatch.Value)).Font.Color = vbRed
Next
End With
Next i
End With
Set Matches = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
2
查看全部评分
-
|