|
- Option Explicit
- Sub 比对提取_学习字典()
- Dim d As Object
- Dim i As Long, j As Long, m As Long, n As Long, k As Long
- Dim Arr, Brr, Crr
- Application.ScreenUpdating = False
- m = Sheet1.Range("A65536").End(xlUp).Row
- n = Sheet2.Range("F65536").End(xlUp).Row
- Set d = CreateObject("scripting.dictionary")
- Arr = Sheet1.Range("A2:B" & m)
- Brr = Sheet2.Range("F1:G" & n)
- For j = 1 To UBound(Brr, 1)
- d(Brr(j, 1) & Brr(j, 2)) = ""
- Next
- ' k = 1
- ReDim Crr(1 To UBound(Arr), 1 To UBound(Arr, 2))
- For i = 1 To UBound(Arr, 1)
- If d.exists(Arr(i, 1) & Arr(i, 2)) Then
- k = k + 1
- Crr(k, 1) = Arr(i, 1)
- Crr(k, 2) = Arr(i, 2)
- ' k = k + 1
- End If
- Next
- [A1].Resize(k, UBound(Arr, 2)) = Crr
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|