Jayadev Sarangi
Member
Hello, I have this below code. but everytime there is a change in color in the range, I have to press F2 then press enter to recalculate teh formula. Can you please guide me in fixing that issue so that whenever there is a change in color the formula recalculates automatically and I do not have press F2 the press enter. Code -
[pre]
[/pre]
[pre]
Code:
Function Colorfunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
Colorfunction = vResult
End Function