|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub TEST1()
Dim vResult, ar, br, i&, j&, t#, regEx As Object, strPat$
Application.DisplayAlerts = False
Application.ScreenUpdating = False
t = Timer
Set regEx = CreateObject("VBScript.RegExp")
regEx.Global = True
ar = [A1].CurrentRegion.Value
br = Range("D5:E5").Value
With Worksheets("关键词")
vResult = Range(.[A1], .Cells(.Rows.Count, "A").End(xlUp)).Value
For j = 1 To 2
strPat = ""
For i = 2 To UBound(ar)
If Len(ar(i, j)) Then strPat = strPat & "|" & ar(i, j)
Next i
regEx.Pattern = Mid(strPat, 2)
For i = 2 To UBound(vResult)
vResult(i, 1) = regEx.Replace(vResult(i, 1), br(1, j))
Next i
Next j
.[A1].Resize(UBound(vResult)) = vResult
.Activate
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "执行完毕!_用时: " & Format(Timer - t, "0.00") & " 秒", 64
End Sub |
评分
-
1
查看全部评分
-
|