|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
如果是真颜色就用此宏
Public Sub rt()
Dim co(), x As Range, n, num()
For i = 1 To Selection.Count
If i = 1 Then n = n + 1: ReDim Preserve co(1 To n): co(n) = Selection(i).Interior.ColorIndex: GoTo 100
If IsNumeric(Application.Match(Selection(i).Interior.ColorIndex, co, 0)) = False Then
n = n + 1
ReDim Preserve co(1 To n): co(n) = Selection(i).Interior.ColorIndex
End If
100:
Next
ReDim num(1 To n)
For i = 1 To Selection.Count
num(Application.Match(Selection(i).Interior.ColorIndex, co, 0)) = num(Application.Match(Selection(i).Interior.ColorIndex, co, 0)) + 1
Next i
MsgBox "color" & Join(co) & Chr(10) & "sum" & Join(num)
End Sub |
|