|
代码如下。。。
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("sheet1")
arr = sht.[a1].CurrentRegion
Set reg = CreateObject("VBScript.RegExp")
ReDim brr(1 To UBound(arr) - 2, 0)
For i = 3 To UBound(arr)
s = arr(i, 4)
With reg
.Pattern = "(\d+)月份"
.Global = False
.IgnoreCase = True
.MultiLine = True
End With
If reg.test(s) Then
Set matchs = reg.Execute(s)
Set mat = matchs(0).submatches
brr(i - 2, 0) = mat(0)
End If
Next
sht.[l3].Resize(UBound(brr)) = brr
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
|
评分
-
2
查看全部评分
-
|