1、 选择【开发工具】 点击鬼粒【Visual Basic】

2、 选择【sheet1】,右击物盯王,选择【插入】,选择【模块】

3、写入代码
Function SumByFontColorAndBGColor(Col As Range, SumRange As Range) '根据字体颜色及背景颜色求和
Application.Volatile
Dim iCell As Range
SumByFontColorAndBGColor = 0
For Each iCell In SumRange
If iCell.Font.Color = Col.Font.Color And iCell.Interior.Color = Col.Interior.Color Then
躲侨 SumByFontColorAndBGColor = SumByFontColorAndBGColor + Application.WorksheetFunction.Sum(iCell)
End If
Next
End Function
4、1. = SumByFontColorAndBGColor(A3,A1:A12)
A3: 根据A3单元格的字体格式和背景色
