|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下。。。
Sub test()
Dim reg, arr(), i, j, k, 起点, 长度
Set reg = CreateObject("vbscript.regexp")
arr = Range("a1").CurrentRegion
For i = 2 To UBound(arr)
Cells(i, 1).Font.Color = 1
With reg
.Global = True
.Pattern = "([一-龢]{2,}).+\1"
Set j = .Execute(arr(i, 1))
If j.Count > 0 Then
s = j(0).submatches(0)
x = InStr(arr(i, 1), s)
Cells(i, 1).Characters(x, Len(s)).Font.Color = 255
x = InStrRev(arr(i, 1), s)
Cells(i, 1).Characters(x, Len(s)).Font.Color = 255
End If
End With
Next i
End Sub
|
|