按下alt+f11,插入 模块
写下过程
Function SUMColor(rag1 As Range, rag2 As Range)
Application.Volatile
For Each i In rag2
If i.Interior.ColorIndex = rag1.Interior.ColorIndex Then
SUMColor = SUMColor + 1
End If
Next
End Function
然后在你需要统计的工作表里面找个空白的单元格(例如D2)填充你要统计个数的颜色,然后在隔壁(+_+)单元格写下:=SUMColor(D2,$A$1:$C$22)。其中$A$1:$C$22是需要统计的区域,根据你的需求自己改。我的例子如图。
本文介绍了一种使用VBA编写的函数SUMColor,该函数能够统计Excel中指定范围内具有相同背景颜色的单元格数量。用户只需在工作表中设置要统计的颜色样本,并应用此函数即可实现快速统计。

2万+

被折叠的 条评论
为什么被折叠?



