1.打开Excel文件,按“Alt+F11”打开VBA编辑窗口,然后在左侧空白处点击右键,“插入”,“模块”。右侧空白处粘贴下面的代码。关闭VBA窗口。
2.然后输入公式:=SUMRED(希望求和的区域)。
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/4ec2d5628535e5ddde71dc6e75c6a7efce1b6225?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
Function sumred(rng As Range) As Double
Dim rg As Range
Set rng = Intersect(ActiveSheet.UsedRange, rng)
For Each rg In rng
If rg.Font.Color = RGB(255, 0, 0) And IsNumeric(rg.Value) Then sumred = sumred + rg.Value
Next
End Function