如何在excel里把单元格字体为红色的数值相加,其他不是红色的数值相加

公式是什么呀?比如在C1到C10中计算字体为红色的求和,其他的求和

1. 进入你的EXCEL文件,按 ALT + F11,进入VBA编辑状态
2. 插入 ---> 模块 , Insert ---> Module
3. 将以下VBA代码贴入
4. 使用该自定义SumColor函数
第一个参数:基准字体颜色单元格,第二个参数就是汇总的范围。
例如:C1-C10,红色的字体求和,
公式 = sumcolor( 选一个任意红色的单元格,C1:C10)

Function SumColor(rColor As Range, rSumRange As Range)
'Sums cells based on a specified Font color.
'以字体颜色求和
Dim rCell As Range
Dim iCol As Integer
Dim vResult
iCol = rColor.Font.ColorIndex
For Each rCell In rSumRange
If rCell.Font.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell) + vResult
End If
Next rCell
SumColor = vResult
End Function
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-09-28
EXCEL2003以下版本,不能对颜色进行判断,2007以上版本可以实现。本回答被提问者采纳
相似回答