Option Explicit
Sub TEST6()
Dim ar, br, cr, dr, i&, j&, k&, n&, r&, strJoin$
Application.ScreenUpdating = False
ar = Sheets("原数1").[A1].CurrentRegion.Value
br = Sheets("统计数2").[A1].CurrentRegion.Value
ReDim cr(UBound(ar) * UBound(br), 1)
cr(0, 0) = "表1 的数": cr(0, 1) = "包含数"
For i = 2 To UBound(br)
strJoin = "," & br(i, 1) & ","
For k = 2 To UBound(ar)
dr = Split(ar(k, 1), ",")
n = 0
For j = 0 To UBound(dr)
If InStr(strJoin, "," & dr(j) & ",") Then n = n + 1
Next j
r = r + 1
cr(r, 0) = ar(k, 1): cr(r, 1) = n
Next k
Next i
With Sheets("统计数2")
.[I1].CurrentRegion.Clear
.[I1].Resize(UBound(cr) + 1, 2) = cr
.Activate
End With
Application.ScreenUpdating = True
Beep
End Sub
|