~~~~VBA 自订函数~~~~
按 Alt-F11 ,功能表/插入/模块,
将以下代码抄入代码编辑窗,关闭编辑窗,自订函数生效了。
D1=xSumif(A$1:A$10,A1)
下拉

Function xSumif(ByVal RNG As Range, ByVal Sample As Range)
Dim output%
On Error Resume Next
For Each cell In RNG
If cell.Font.Color = Sample.Font.Color Then
output = output + cell.Value
End If
Next
On Error GoTo 0
xSumif = output
End Function