|
Sub try()
Dim i As Long
Dim j As Long
Dim tbl, tbl2, v, k
With CreateObject("Scripting.Dictionary")
tbl = Range("D2", Range("D" & Rows.Count).End(xlUp)).Value
tbl2 = Range("B2", Range("B" & Rows.Count).End(xlUp)).Value
For Each v In tbl
.Item(v) = .Item(v) + 1
Next
For Each v In tbl2
If .Exists(v) Then
.Item(v) = .Item(v) - 1
If .Item(v) = 0 Then .Remove v
End If
Next
i = 0
For Each k In .Keys
For j = 1 To .Item(k)
i = i + 1
tbl(i, 1) = k
Next
Next
End With
Range("F:F").ClearContents
Range("F2").Resize(i).Value = tbl
End Sub
こんな感じです。
|
|