Option Explicit
Sub TEST3()
Dim ar, br, i&, j&, r&, strJoin$, strJoin1$
Application.ScreenUpdating = False
ar = [AC1].CurrentRegion.Value
br = [AK1].CurrentRegion.Value
ReDim cr(1 To UBound(ar), 1 To UBound(ar, 2))
For i = 2 To UBound(ar)
strJoin1 = Join(Application.Index(ar, i))
strJoin = strJoin & "," & strJoin1
Next i
strJoin = strJoin & ","
For i = 2 To UBound(br)
strJoin1 = "," & Join(Application.Index(br, i)) & ","
If InStr(strJoin, strJoin1) Then
r = r + 1
For j = 1 To UBound(br, 2)
cr(r, j) = br(i, j)
Next j
End If
Next i
If r Then
[Az1].Resize(r, UBound(cr, 2)) = cr
Else
MsgBox "没有交集"
End If
Application.ScreenUpdating = True
Beep
End Sub
|