|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim flg As Boolean
- Dim hj(6 To 9) As Double
- tt = Timer
- flg = False
- For i = 6 To 9
- hj(i) = 0
- Next
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("a5:i" & r).Interior.ColorIndex = 0
- arr = .Range("a5:i" & r)
- For i = UBound(arr) - 1 To 1 Step -1
- bm = arr(i, 1)
- j = i + 1
- Do While arr(j, 1) Like bm & "*"
- If arr(j, 1) Like bm & "??" Or arr(j, 1) Like bm & "???" Then
- For k = 6 To 9
- hj(k) = hj(k) + arr(j, k)
- Next
- flg = True
- End If
- j = j + 1
- Loop
- If flg Then
- For k = 6 To 9
- arr(i, k) = hj(k)
- hj(k) = 0
- Next
- .Cells(i + 4, 6).Resize(1, 4).Interior.ColorIndex = 4
- flg = False
- End If
- Next
- .Range("a5").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- MsgBox "数据汇总完毕,共用时" & Timer - tt & "秒"
- End Sub
复制代码 |
|