关于Excel统计有多少个单元格的文字是红色、黑色?

举例如下,用函数统计出来有多少个红色字体的单元格,多少个黑色字体的单元格。谢谢啦。

   如图,统计A列红色字体的个数。步骤是:

  第一步,定义名称。

  点击“公式”、“定义名称”。在“新建名称”对话框中,“名称”中输入如X,“引用位置”中输入

  =GET.CELL(24,Sheet2!A1)

  确定。

  第二步,在B1单元格中输入

  =X

  向下拖公式,公式值为3的即红色。

  第三步,在C1中输入

  =COUNTIF(B:B,3)

  即是A列红色字体的个数。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-03-19

可以按格式查找,替换成1,再用countif统计1的数量,前提是做好备份

先对红色的做一遍,再对黑色的做一遍

本回答被网友采纳
第2个回答  2015-03-19
如果你想通过函数来实现,那就要自己用VBA写自定义函数了。你可以百度查一下:CountColor 和SumColor函数,以下是别人写的自定义函数,参考后可以照搬或者修改后再用。

方法:

打开你的工作表:点开发工具-Visual
Basic-左边上边的小窗口空白处点右键-插入-模块,然后在打开的编辑框中粘贴以下代码:
Function CountColor(col As
Range, countrange As Range) As Integer
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) As
Integer
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

然后关闭,反回到工作表,点击宏安全性-选择启用所有宏,并勾选信任对VBA工程的访问,保存关闭

用法:
按颜色求和:sumcolor(颜色示列格,求和区域或列);按颜色计数:countcolor(颜色示列格,求和区域或列)
例如:要求和从a1到a10这个区域内的红色格,
=sumcolor($a$1,$a$1:$A$10)
计数:countcolor($a$1,$a$1:$A$10)
注意:$a$1
必须是红色格,这是定义颜色的,你也可以设成其它格,但必须是你要求和的颜色
第3个回答  2015-03-19
Sub test()
Dim rg As Range
For Each rg In Range("a1:z100")
If rg.Font.ColorIndex = 1 And rg <> "" Then
n = n + 1
End If
If rg.Font.ColorIndex = 3 And rg <> "" Then
m = m + 1
End If
Next
MsgBox "红色单元格共计" & m & Chr(13) & "黑色单元格共计" & n
End Sub
第4个回答  2015-03-19
好像没有现存的公式,
用VBA做吧,
相似回答