|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:g" & r)
- For i = 1 To UBound(arr)
- xm = arr(i, 1) & "+" & arr(i, 4) & "+" & arr(i, 7)
- If Not d.exists(xm) Then
- d(xm) = i
- Else
- m = d(xm)
- arr(m, 6) = arr(m, 6) + arr(i, 6)
- End If
- Next
- For Each aa In d.items
- xm = arr(aa, 1) & "+" & arr(aa, 4)
- If Not d1.exists(xm) Then
- ReDim brr(1 To 7)
- For j = 1 To UBound(arr, 2)
- brr(j) = arr(aa, j)
- Next
- Else
- brr = d1(xm)
- brr(7) = brr(7) & "," & arr(aa, 7)
- End If
- d1(xm) = brr
- Next
-
- End With
- With Worksheets("结果")
- .UsedRange.Offset(1, 0).Clear
- .Range("a2").Resize(d1.Count, 7) = Application.Transpose(Application.Transpose(d1.items))
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|