Macro for counting colours not running automatically

Viewed 22

I have a function to count all coloured cells. But it if I choose all cells, do a massive change, it doesn't recalculate the formula. It stucks in previous value.

How can I change that ?

Thanks in advance

Function GetColorCount(CountRange As Range, CountColor As Range)
Dim CountColorValue As Integer
Dim TotalCount As Integer
CountColorValue = CountColor.Interior.ColorIndex
Set rCell = CountRange
For Each rCell In CountRange
If rCell.Interior.ColorIndex = CountColorValue Then
    TotalCount = TotalCount + 1
End If
Next rCell
GetColorCount = TotalCount
End Function
0 Answers
Related