excel怎么统计颜色相同的单元格数量

如题所述

第1个回答  2024-01-05
在excel中统计相同颜色单元格的数量,用VBA代码处理吧。
第一步,在VBA编辑器中插入新模块。
第二步,把下面的代码复制到模块中。创建新函数CColor.
Function CColor(Crange as range,Col as range)
dim n as range
application.Volatile
For each n in crange
If n.Interior.ColorIndex = Col.Interior.ColorIndex
CColor = CColor +1
End if
Next n
End Function
第三步,使用函数。数据在A1:A10,统计放B1,B1=CCOLOR(A1:A10,A1).
本例中,公式统计A1:A10区域中,与A1单元格颜色一样的数量。
相似回答