|
不给你事件了,给你按钮吧。
用下面的代码,自己弄个按钮,我把关键字改成“责任”了。如果你的模拟数据没问题,我的代码可以说是完美解决了你的问题。匹配责任比匹配已阅读更简单。。。。
别忘了多给我几朵献花。。。。
- Sub d()
- Dim Reg As Object, Mac As Object, dic As Object, M As Object, arr(), brr()
- Set Reg = CreateObject("VBScript.RegExp"): Set dic = CreateObject("Scripting.Dictionary")
- brr = Range("b4").CurrentRegion.Resize(, 2): Reg.Global = 1: Reg.Pattern = "([一-龥]+).+(责任)"
- Set Mac = Reg.Execute([A2]): ReDim arr(1 To Mac.Count, 1 To 2)
- For Each M In Mac
- r = r + 1: c = 0
- For Each ii In M.SubMatches
- c = c + 1: arr(r, c) = ii
- Next
- dic(arr(r, 1)) = ""
- Next
- For i = 2 To UBound(brr)
- If dic.Exists(brr(i, 1)) Then
- brr(i, 2) = "是"
- Else
- brr(i, 2) = "否"
- End If
- Next
- Range("c4").Resize(65500, 1).ClearContents: Range("b4").CurrentRegion.Resize(, 2) = brr
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|