在Excel中如何统计不同颜色单元格底纹的单元格个数

如题所述

在excel2003中这样有用的。
按下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是需要统计的区域,根据你的需求自己改。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-04-18
用自定函数ZHYZ(单元格区域,样本颜色所在的单元格)
Function ZHYZ(rag1 As Range, rag2 As Range)
Application.Volatile
For Each i In rag2
If i.Interior.ColorIndex = rag1.Interior.ColorIndex Then
ZHYZ = ZHYZ + 1
End If
Next
End Function

参考资料:http://club.excelhome.net/thread-504871-1-1.html

相似回答