|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
代码如下。。。
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) - 1, 0)
For i = 2 To UBound(arr)
With reg
.Pattern = "(\d+)月"
.Global = False
.IgnoreCase = True
.MultiLine = True
End With
If reg.test(arr(i, 1)) Then
Set matchs = reg.Execute(arr(i, 1))
Set mat = matchs(0).submatches
brr(i - 1, 0) = mat(0)
End If
Next
sht.[d2].Resize(UBound(brr)) = brr
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
|
评分
-
3
查看全部评分
-
|