EXCAL
中同色单元格相加公式
=sumcolor($AK$5,$D$5:$AJ$5)
打开你的工作表:点开发工具
-Visual
Basic-
左边上边的小窗口空白处点右键
模块,然
后在打开的编辑框中粘贴以下代码:
Function CountColor(col As Range, countrange As Range) As Integer
Dim icell As Range
Application.V
olatile
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.V
olatile
For Each icell In sumrange
If icell.Interior.ColorIndex = col.Interior.ColorIndex Then
SumColor = Application.Sum(icell) + SumColor
End If
Next icell
End Function
——————————————————————————————————–
EXCAL
中同色数字相加公式
=COLORSUM(A1:A100,A2)
打开你的工作表:点开发工具
-Visual
Basic-
左边上边的小窗口空白处点右键
模块,然
后在打开的编辑框中粘贴以下代码:
Function COLORSUM(xx As Range, yy As Range) As Double
y = yy.Font.ColorIndex
For Each x In xx
If x.Font.ColorIndex = y Then
xxx = xxx + x.Value
End If
Next
COLORSUM = xxx
原文链接:https://wenku.baidu.com/view/30ae4dc09ec3d5bbfd0a74b7.html