|
Sub test()
With Sheet1
.Range("c2:d10000").ClearContents
Dim arr: arr = .Range("a1:a" & .Cells(Rows.Count, 1).End(xlUp).Row)
ReDim ar(1 To UBound(arr), 1 To 1)
Dim brr: brr = .Range("b1:b" & .Cells(Rows.Count, 2).End(xlUp).Row)
ReDim br(1 To UBound(arr), 1 To 1)
Dim dic: Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
a = arr(i, 1)
If Not dic.exists(a) Then
dic(a) = 1
Else
m = m + 1
ar(m, 1) = "'" & a
End If
Next
.Range("c2").Resize(m, 1) = ar
dic.RemoveAll
For j = 2 To UBound(brr)
b = brr(j, 1)
If Not dic.exists(b) Then dic(b) = 1
Next
For i = 2 To UBound(arr)
a = arr(i, 1)
If dic(a) <> 1 Then
n = n + 1
br(n, 1) = "'" & a
End If
Next
.Range("d2").Resize(n, 1) = br
End With
MsgBox "完成"
End Sub |
|