如何在Excel中统计相同颜色单元格的数量?

如题所述

    在Excel中统计相同颜色单元格的数量,需要先编辑自定义函数,然后,再使用此自定义函数来统计。方法如下:

    自定义函数名称为CountColor,代码内容如下:

Function CountColor(Countrange as range,Col as range)

Dim n As Range

Application.Volatile

For Each n In Countrange

If n.Interior.ColorIndex = Col.Interior.ColorIndex Then

CountColor =CountColor + 1

End If

Next n

End Function

    使用CountColor,参数有二个,参数一,统计区域,参数二指定颜色的单元格。

    请点击输入图片描述

温馨提示:答案为网友推荐,仅供参考
相似回答