|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下。。。Sub test()
Set reg = CreateObject("vbscript.regexp")
Set rg = CreateObject("vbscript.regexp")
Dim brr(1 To 10000, 1 To 1)
With Sheet1
arr = .Range("a1:a" & .Cells(.Rows.Count, 1).End(3).Row)
If IsArray(arr) Then
For i = 1 To UBound(arr)
With reg
.Pattern = "\d+\..+?(?=[\d])|\d+\..+?$"
.Global = True
If .test(arr(i, 1)) Then
Set s = .Execute(arr(i, 1))
End If
End With
For j = 0 To s.Count - 1
With rg
.Pattern = "\d+.*?(?=[A-E]\.)|[A-E]\..*?(?=[A-E]\.)|[A-E]\..*$"
.Global = True
If .test(arr(i, 1)) Then
Set ss = .Execute(s(j))
End If
End With
For k = 0 To ss.Count - 1
n = n + 1
brr(n, 1) = ss(k)
Next
Next
Next
Else
With reg
.Pattern = "\d+\..+?(?=[\d])|\d+\..+?$"
.Global = True
If .test(arr) Then
Set s = .Execute(arr)
End If
End With
For j = 0 To s.Count - 1
With rg
.Pattern = "\d+.*?(?=[A-E]\.)|[A-E]\..*?(?=[A-E]\.)|[A-E]\..*$"
.Global = True
If .test(arr) Then
Set ss = .Execute(s(j))
End If
End With
For k = 0 To ss.Count - 1
n = n + 1
brr(n, 1) = ss(k)
Next
Next
End If
.[c2].Resize(n, 1) = brr
End With
Beep
End Sub
|
|