参与一下。。。
- Sub 需求汇总()
- Application.ScreenUpdating = False
- Dim i As Integer, arr, brr, str As String
- arr = Sheets("结果").Range("a1:q" & Cells(Rows.Count, 1).End(3).Row)
- Set d = CreateObject("scripting.dictionary")
- p = ThisWorkbook.Path & ""
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- k = 1
- brr(k, 1) = arr(1, 1)
- brr(k, 2) = arr(1, 2)
- brr(k, 3) = arr(1, 3)
- For i = 2 To UBound(arr)
- str = arr(i, 1) & arr(i, 2)
- If Not d.exists(str) Then
- k = k + 1
- d(str) = k
- brr(k, 1) = arr(i, 1)
- brr(k, 2) = arr(i, 2)
- brr(k, 3) = arr(i, 9)
- Else
- r = d(str)
- brr(r, 3) = brr(r, 3) + arr(i, 9)
- End If
- Next
- Set wb = Workbooks.Add
- wb.Sheets(1).Range("a1").Resize(k, 3) = brr
- wb.SaveAs p & " 另存文件"
- wb.Close
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|