|
- Sub qq()
- Dim d, arr, i%, j%, brr(), s1#, s2#, t
- Set d = CreateObject("Scripting.Dictionary")
- arr = [a1].CurrentRegion
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 2)) Then
- d(arr(i, 2)) = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 4) & "|" & arr(i, 5)
- Else
- s1 = arr(i, 3)
- s2 = arr(i, 4)
- If s1 < Split(d(arr(i, 2)), "|")(2) Then
- If s2 < Split(d(arr(i, 2)), "|")(3) Then
- d(arr(i, 2)) = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 4) & "|" & arr(i, 5)
- End If
- End If
- End If
- Next
- t = d.items
- ReDim brr(1 To d.Count, 1 To 5)
- For i = 1 To d.Count
- For j = 1 To 5
- brr(i, j) = Split(t(i - 1), "|")(j - 1)
- Next
- Next
- Sheet2.Cells.Clear
- Sheet2.[a1].Resize(d.Count, 5) = brr
- End Sub
复制代码 |
|