Sub test()
Dim Arr, xD, Reg, xE, T$, T1$, i%, j%, a
Set xD = CreateObject("Scripting.Dictionary")
Set Reg = CreateObject("VBScript.RegExp")
Arr = Range([d1], [d65536].End(3))
For i = 2 To UBound(Arr): T = Arr(i, 1): xD(T) = "": Next
Arr = Range([b1], [a65536].End(3))
For i = 2 To UBound(Arr)
T = Arr(i, 1)
With Reg
.Global = True
.IgnoreCase = True
.Pattern = "[\u4e00-\u9fa5()]+"
Set xE = .Execute(T)
a = Split(Trim(.Replace(T, "")), "、")
For j = 0 To UBound(a)
If Left(a(j), 2) <> "AA" Then
pos = InStr(1, a(j), "AA")
T = Mid(a(j), pos, Len(a(j)))
Else
T = a(j)
End If
If xD.Exists(T) Then: T1$ = T1$ & "、" & T
Next
Arr(i, 2) = Mid(T1, 2): T1 = ""
End With
Next
[a1].Resize(UBound(Arr), 2) = Arr
End Sub作者: hcm19522 時間: 2021-11-8 16:12
Option Explicit
Sub TEST()
Dim Brr, Crr, i&, x%, T$, T1$
Brr = Range([D2], [D65536].End(3))
Crr = Range([A2], [A65536].End(3))
For i = 1 To UBound(Crr)
T = Crr(i, 1)
Crr(i, 1) = ""
For x = 1 To UBound(Brr)
T1 = Trim(Brr(x, 1)): If T1 = "" Then GoTo x01
If InStr(T, T1) Then
Crr(i, 1) = IIf(Crr(i, 1) = "", T1, Crr(i, 1) & "、" & T1)
End If
x01: Next
Next
[C2].Resize(UBound(Crr), 1) = Crr
End Sub