excel:计算填充色有多少个?

怎样计算$c8:$k8中填充为红色的单元格有多少个?

excel函数中自带是没有对颜色单元格计数的
可以利用宏表函数进行处理,但是比较麻烦
大家如何用EXCEL来根据单元格的颜色来计数和求和呢,大家看这里。
STEP 1 :打开你的excel;
STEP 2 :菜单栏:工具-宏-Visual Basic 编辑器;
STEP 3 :Visual Basic 编辑器菜单栏: 插入-模块
STEP 4 :贴入下面这段函数
Function Countcolor(col As Range, countrange As Range)
Dim icell As Range
Application.Volatile
For Each icell In countrange
If icell.Interior.ColorIndex = col.Interior.ColorIndex Then
Countcolor = Countcolor + 1
End If
Next icell
End Function
Function Sumcolor(col As Range, sumrange As Range)
Dim icell As Range
Application.Volatile
For Each icell In sumrange
If icell.Interior.ColorIndex = col.Interior.ColorIndex Then
Sumcolor = Application.Sum(icell) + Sumcolor
End If
Next icell
End Function
STEP 5 :保存并关闭Visual Basic 编辑器
STEP 6 :使用函数 countcolor(所要统计的颜色所在单元格,统计的区域)
sumcolor(所要统计的颜色所在单元格,统计的区域)
///若是字体颜色
Function Sumfontcolor(col As Range, sumrange As Range)
Dim icell As Range
Application.Volatile
For Each icell In sumrange
If icell.Font.ColorIndex = col.Font.ColorIndex Then
Sumfontcolor = Application.Sum(icell) + Sumfontcolor
End If
Next icell
End Function

问:excel2003中如何根据指定单元格颜色来计数?类似countif功能的 比如我需要确认一张表格里 散乱分布的红色单元格的个数 然后把这个数放到指定位置。
答:添加模块,复制代码
Function countcolour(target As Range)
Dim cell As Range
Dim cnt As Integer
cnt = 0
For Each cell In target
If cell.Interior.ColorIndex = 3 Then cnt = cnt + 1
Next cell
countcolour = cnt
End Function
在单元格中引用countcolour即可。如在F1中输入=countcolour(A1:D5)就是统计A1到D5中红色单元格的个数.注意是单元格颜色,不是字体颜色.

以上是自定义函数处理 !
温馨提示:答案为网友推荐,仅供参考
相似回答