|
Sub TEST()
Dim arr, brr, i&, j&, dic As Object, strTxt$
Set dic = CreateObject("Scripting.Dictionary")
arr = [E1].CurrentRegion
For i = 2 To UBound(arr)
dic(arr(i, 1)) = arr(i, 1)
Next i
arr = [A1].CurrentRegion
ReDim Preserve arr(1 To UBound(arr), 1 To 4)
arr(1, 4) = "代号": brr = dic.keys
For i = 2 To UBound(arr)
strTxt = arr(i, 3): arr(i, 3) = "": arr(i, 4) = 0
For j = 0 To UBound(brr)
If InStr(strTxt, brr(j)) Then
arr(i, 3) = dic(brr(j))
arr(i, 4) = 1
Exit For
End If
Next j
Next i
[G1].Resize(UBound(arr), 4) = arr
Set dic = Nothing
Beep
End Sub
|
|