Custom functions don't automatically update when you change the format (color) of a cell. They will automatically update if you change the value of a cell.
An imperfect solution: Add this at the top of the macro, it will recalculate the custom function when any value (not background color) on the sheet is changed. You could also press the F9 key to force the custom functions to update.
Function SumColor(Color As Range, Range As Range) As Long
Application.Volatile
Dim Cell As Range
Dim ColorIndexNumber As Integer
Dim ColorSum
ColorIndexNumber = Color.Interior.ColorIndex
For Each Cell In Range
If Cell.Interior.ColorIndex = ColorIndexNumber Then
ColorSum = WorksheetFunction.Sum(Cell.Value) + ColorSum
End If
Next Cell
SumColor = ColorSum
End Function
Bookmarks