|
VBA 如果把结果放在H~J列
Private Sub CommandButton1_Click()
Dim i, j, n, arr, brr, crr()
Application.ScreenUpdating = False
[h1].CurrentRegion.Offset(1).ClearContents
Set d = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
brr = Range("D1:D" & Range("d65536").End(xlUp).Row)
ReDim crr(1 To UBound(arr), 1 To 3)
For j = 2 To UBound(brr)
For i = 2 To UBound(arr)
If InStr(arr(i, 3), brr(j, 1)) Then
n = n + 1
d(arr(i, 3)) = n
crr(n, 1) = arr(i, 1)
crr(n, 2) = arr(i, 2)
crr(n, 3) = arr(i, 3)
End If
Next
Next
[h2].Resize(n, 3) = crr
End Sub |
|