Hi all, I have a code below that counts the number of coloured cells of a specific colour. The problem is that it does not recalculate when the cell colour changes. It only updates when I type something in the sheet. From what I understand this is due to
This does not trigger recalculation due to cell colour changes. Is there a way to make my code trigger a recalculation when there are cell colour changes?
Thanks!
VBA Code:
Application.Volatile
VBA Code:
Function ColorFunction(rColor As Range, rRange As Range)
Dim rCell As Range
Dim lCol As Long
Dim vResult
Application.Volatile
lCol = rColor.Interior.ColorIndex
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
ColorFunction = vResult
End Function