All_At_Sea
New Member
- Joined
- Aug 25, 2024
- Messages
- 10
- Office Version
- 365
- Platform
- Windows
Good Morning,
I have the following code in a Module: -
With the following sheet: -
The UDF works fine each time I manually edit the Formula and press enter. However, if I then change the Color in one of the Cells in Column B, the result/count in D doesn't update/recalculate.
I've checked and Calculation Options is set to Automatic and tried forcing it to Recalculate by pressing both the Calculate Now and Calculate Sheet buttons on the Ribbon.
I'm stumped as to the cause.
Any ideas?
I have the following code in a Module: -
VBA Code:
Function CountColor(rng As Range, colorcell As Range) As Long
Dim cell As Range
Dim clr As Long
clr = colorcell.Interior.Color
For Each cell In rng
If Evaluate("GetColor(" & cell.Address(External:=True) & ")") = clr Then
CountColor = CountColor + 1
End If
Next cell
End Function
Function GetColor(cell As Range) As Long
GetColor = cell.DisplayFormat.Interior.Color
End Function
With the following sheet: -
Cell Formulas | ||
---|---|---|
Range | Formula | |
E3 | E3 | =CountColor(B3:B5,D3) |
E4 | E4 | =CountColor(B3:B5,D4) |
The UDF works fine each time I manually edit the Formula and press enter. However, if I then change the Color in one of the Cells in Column B, the result/count in D doesn't update/recalculate.
I've checked and Calculation Options is set to Automatic and tried forcing it to Recalculate by pressing both the Calculate Now and Calculate Sheet buttons on the Ribbon.
I'm stumped as to the cause.
Any ideas?