|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Public Sub abc()
- Dim ar, br, cr, rep, i, ii, lenth
- ar = Range([a2], [a65536].End(3))
- br = Range([b2], [b65536].End(3))
- ReDim cr(1 To UBound(br), 1 To 1)
- Set rep = CreateObject("vbscript.regexp")
- rep.Global = True
- rep.Pattern = "^\w+| .*$"
- For i = 1 To UBound(br)
- br(i, 1) = rep.Replace(br(i, 1), "")
- Next
- For i = 1 To UBound(ar)
- For ii = 1 To UBound(br)
- rep.Pattern = "[" & br(ii, 1) & "]"
- lenth = Len(ar(i, 1))
- If rep.Execute(ar(i, 1)).Count >= Int(lenth * 0.8) Then
- cr(ii, 1) = ar(i, 1)
- Exit For
- End If
- Next
- Next
- [c2].Resize(UBound(cr)) = cr
- End Sub
复制代码
|
|