|
- Sub test0() '据 8F要求 参与一下
- Dim ar, br() As Long, cr(), Dict As Object
- Dim i As Long, j As Integer, k As Integer, posRow As Long
- Dim rowSize() As Long, strKey As String
-
- Application.ScreenUpdating = False
-
- Sheet3.Activate
- Cells.Clear
-
- Set Dict = CreateObject("Scripting.Dictionary")
- ar = Sheet1.Range("A1").CurrentRegion.Resize(, 2)
- For i = 1 To UBound(ar)
- Dict.Add ar(i, 1) & "|" & ar(i, 2), i
- Next
-
- ar = Sheet2.Range("A1").CurrentRegion.Resize(, 3)
- ReDim br(1 To UBound(ar), 1 To UBound(ar, 2) + 1)
- ReDim cr(1 To Dict.Count)
- ReDim rowSize(1 To Dict.Count)
-
- For k = 1 To UBound(cr)
- cr(k) = br
- Next
-
- For i = 1 To UBound(ar)
- strKey = ar(i, 1) & "|" & ar(i, 2)
- If Dict.exists(strKey) Then
- k = Dict(strKey)
- rowSize(k) = rowSize(k) + 1
- For j = 1 To UBound(ar, 2)
- cr(k)(rowSize(k), j) = ar(i, j)
- Next
- cr(k)(rowSize(k), j) = k
- End If
- Next
-
- For k = 1 To UBound(cr)
- Range("A" & posRow + 1).Resize(rowSize(k), UBound(cr(k), 2)) = cr(k)
- posRow = posRow + rowSize(k)
- Next
-
- Set Dict = Nothing
- Application.ScreenUpdating = True
- Beep
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|