|
- Sub zc()
- Dim dic As Object
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet3.Range("A1:I" & Sheet3.Cells(Rows.Count, 1).End(xlUp).Row)
- For i = 2 To UBound(arr)
- Key = arr(i, 6) & "," & arr(i, 7)
- If Not dic.Exists(Key) Then
- dic(Key) = arr(i, 2)
- Else
- dic(Key) = dic(Key) & "," & arr(i, 2)
- End If
- Next
- keys = dic.keys
- items = dic.items
- ReDim brr(1 To dic.Count, 1 To 3)
- For i = 0 To dic.Count - 1
- k = k + 1
- s = Split(keys(i), ",")
- brr(k, 1) = s(0)
- brr(k, 2) = s(1)
- brr(k, 3) = items(i)
- Next
- Sheet1.Range("E2:G" & Rows.Count).ClearContents
- Sheet1.Range("e2").Resize(k, 3) = brr
- End Sub
复制代码
|
|