|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim Dic As Object, tt, ii%, n%, ss%
- Set Dic = CreateObject("Scripting.Dictionary")
- With Sheet1
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
-
- For i = 2 To r
- TmpColor = .Cells(i, 1).Interior.ColorIndex
- Dic(TmpColor) = ""
- Next
- For m = 0 To Dic.Count - 1
- ii = 1: tt = 0
- For n = 2 To r
- If .Cells(n, 1).Interior.ColorIndex = Dic.keys()(m) Then
- .Cells(n, 2) = ii
- ii = ii + 1
- tt = tt + .Cells(n, 1)
- ss = n
- End If
- Next
- .Cells(ss, 3) = tt
- Next
- End With
- End Sub
复制代码 |
|