|
楼主 |
发表于 2018-3-1 09:43
|
显示全部楼层
如果要自定义输入关键词,直接将责任改为单元格引用不行啊,再指导下。我的鲜花只给你了!
- 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 = "([一-龥]+).+([b2])"
- 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
复制代码
|
|