So I have this function that counts cells of a color on a range
I want the function cell to be refreshed each time a cell on the given range changes colour. Also, is there a way to incorporate this inside the function code or does it have to be a seperate sub ?
VBA Code:
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