|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.CountLarge <> 1 Then Exit Sub
If Target.Column <> 1 Then Exit Sub
If Target.Row = 1 Then Exit Sub
If Len(Target) * Len(Target.Offset(0, 1)) = 0 Then Exit Sub
If InStr(Target.Offset(0, 1), ",") = 0 Then
str1 = Target.Offset(0, 1)
Else
arr = Split(Target.Offset(0, 1), ",")
For j = 0 To UBound(arr)
For i = j + 1 To UBound(arr)
If Len(arr(i)) > Len(arr(j)) Then
tm = arr(i)
arr(i) = arr(j)
arr(j) = tm
End If
Next i
Next j
str1 = Join(arr, "|")
End If
Application.ScreenUpdating = False
r = Cells(Rows.Count, 2).End(3).Row
arr = [b1].Resize(r)
Range("b2:b" & r).Font.ColorIndex = 0
With CreateObject("vbscript.regexp")
.Pattern = str1
.Global = True
For j = 2 To UBound(arr)
For Each m In .Execute(arr(j, 1))
Cells(j, 2).Characters(m.FirstIndex + 1, m.Length).Font.ColorIndex = 3
Next
Next j
End With
Application.ScreenUpdating = True
End Sub |
|