|As far as I can tell, you have 2 issues:|
1 - User Defined Functions (UDF) don't recalculate automatically unless you inlcude the line:
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
lCol = rColor.Interior.ColorIndex
2 - Even if you include that line, changing a cell color does not cause the sheet to recalculate like changing a value would.
So, I think you need to do 2 things:
1 - Add that line to your code.
2 - Force a calculation
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
You can refine that by limiting the range in which a mere selection forces a recalculation, but I think you get the idea.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.