|
Sub yanse()
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("报名")
r = .Cells(Rows.Count, 1).End(xlUp).Row
.Columns("B:B").Font.ColorIndex = 0
For i = 2 To r
d.RemoveAll
If Trim(.Cells(i, 2)) <> "" Then
If InStr(.Cells(i, 2), "、") > 0 Then
rr = Split(.Cells(i, 2), "、")
For s = 0 To UBound(rr)
If rr(s) <> "" Then
d(rr(s)) = d(rr(s)) + 1
End If
Next s
zf = Trim(.Cells(i, 2))
For Each k In d.keys
sl = d(k)
If sl > 1 Then
wz = InStr(zf, k)
gs = Len(k)
.Cells(i, 2).Characters(Start:=wz, Length:=gs).Font.ColorIndex = 3
wz = InStrRev(zf, k)
gs = Len(k)
.Cells(i, 2).Characters(Start:=wz, Length:=gs).Font.ColorIndex = 3
End If
Next k
End If
End If
Next i
End With
MsgBox "ok!"
End Sub
|
|