|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim arr, brr, crr(1 To 10000, 1 To 2), drr(1 To 10000, 1 To 2)
Dim dic
Set dic = CreateObject("scripting.dictionary")
arr = Sheets(1).[a1].CurrentRegion
For x = 2 To UBound(arr)
If Len(arr(x, 1) & arr(x, 2)) Then
dic(arr(x, 1) & "|" & arr(x, 2)) = ""
End If
Next
brr = Sheets(2).[a1].CurrentRegion
For i = 2 To UBound(brr)
If dic.exists(brr(i, 1) & "|" & brr(i, 2)) Then
m = m + 1
drr(m, 1) = brr(i, 1)
drr(m, 2) = "'" & brr(i, 2)
dic.Remove brr(i, 1) & "|" & brr(i, 2)
Else
k = k + 1
crr(k, 1) = brr(i, 1)
crr(k, 2) = "'" & brr(i, 2)
End If
Next
If m > 0 Then
Sheets(3).[a2].Resize(m, 2) = drr
End If
If k > 0 Then
Sheets(4).[a2].Resize(k, 2) = crr
End If
End Sub
|
|