|
- Sub 查询()
- Dim arr, i&, j&, x, d, k&, d1, a
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Sheets(1)
- arr = .[a1].CurrentRegion
- For i = 2 To UBound(arr)
- x = arr(i, 1) & arr(i, 2)
- d(x) = arr(i, 3)
- Next
- End With
- Sheets(5).[a2:d10000].ClearContents
- For k = 2 To 4
- With Sheets(k)
- arr = .[a1].CurrentRegion
- For i = 2 To UBound(arr)
- x = arr(i, 1) & arr(i, 2)
- If d.exists(x) And arr(i, 3) > d(x) Then
- Set d1(x) = .Cells(i, 1).Resize(1, 4)
- End If
- For Each a In d1.keys
- d1(a).Copy Sheets(5).Cells(Rows.Count, 1).End(3).Offset(1, 0)
- d1.Remove (a)
- Next
- Next
- End With
- Next
- End Sub
复制代码 |
|