这个需要自定义函数 Function colorcount(y As Range, rng) Application.Volatile Dim c As Double Dim x As Range For Each x In rng If x.Interior.ColorIndex = y.Interior.ColorIndex Then c = 1 Else c = 0 End If colorcount = colorcount + c Next x End Function 复制以上代码备用 按键盘上的Alt+F11打开VBA程序 单击插入命令/插入模块 在右边空白处粘贴代码 回到你的表格中 在你需要显示个数的位置I1输入公式=colorcount(C1,A1:H3)回车即可 效果如下图 |
|