|
- Sub sdd()
- Dim brr(), crr()
- arr = Sheet1.[A1].CurrentRegion
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arr)
- d1(arr(i, 2)) = ""
- d(arr(i, 2) & "-" & arr(i, 10)) = d(arr(i, 2) & "-" & arr(i, 10)) + 1
- Next i
- k = d.keys
- t = d.items
- k1 = d1.keys
- For i = 0 To d.Count - 1
- n = n + 1
- ReDim Preserve brr(1 To 3, 1 To n)
- brr(1, n) = Split(k(i), "-")(0)
- brr(2, n) = Split(k(i), "-")(1)
- brr(3, n) = t(i)
- Next i
- For i = 0 To d1.Count - 1
- For j = 1 To UBound(brr, 2)
- If brr(1, j) = k1(i) Then
- n1 = n1 + 1
- ReDim Preserve crr(1 To 3, 1 To n1)
- crr(1, n1) = n1
- crr(2, n1) = brr(2, j)
- crr(3, n1) = brr(3, j)
- End If
- Next j
- Sheet2.Cells(Sheet2.Range("b65536").End(xlUp).Row + 4, 2).Resize(UBound(crr, 2), 3) = Application.Transpose(crr)
- n1 = 0
- Next i
- End Sub
复制代码 |
|