An interesting thing I came across and I was wondering if anybody else has seen it and is there a work-around. Here's my code
Function SumByColor(CellColor As Range, rRange As Range)
Application.volatile
Dim cSum As Double
Dim ColIndex As Integer
Dim TempNumber As String
ColIndex = CellColor.Font.ColorIndex
For Each cl In rRange
If cl.Font.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function
I have a column of numbers. Some have FontColor = Orange, some have fontColor = Black. I want to sum everything where fontColor=black.
The reference cell/font (ColIndex) is Black
SumByColor will sum the black cells but if I change an orange cell black or a black cell orange SumByColor does not update.
It does recalculate if you change the value of any cell on the sheet.
Can anybody confirm this and is there a way I can get SumByColor to update by changing the font color?
Function SumByColor(CellColor As Range, rRange As Range)
Application.volatile
Dim cSum As Double
Dim ColIndex As Integer
Dim TempNumber As String
ColIndex = CellColor.Font.ColorIndex
For Each cl In rRange
If cl.Font.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function
I have a column of numbers. Some have FontColor = Orange, some have fontColor = Black. I want to sum everything where fontColor=black.
The reference cell/font (ColIndex) is Black
SumByColor will sum the black cells but if I change an orange cell black or a black cell orange SumByColor does not update.
It does recalculate if you change the value of any cell on the sheet.
Can anybody confirm this and is there a way I can get SumByColor to update by changing the font color?