Chrispykill
New Member
- Joined
- Aug 11, 2017
- Messages
- 2
Hi,
I am using a VBA to count cells based on their fill colour. I am using the following script:
Function CountColor(Rng As Range, RngColor As Range) As Integer
Application.Volatile True
Dim Cll As Range
Dim Clr As Long
Clr = RngColor.Range("A1").Interior.Color
For Each Cll In Rng
If Cll.Interior.Color = Clr Then
CountColor = CountColor + 1
End If
Next Cll
End Function
Then in the cell I am using this formula:
=countcolor(B7:Q7,W7)
Where B7:Q7 is the range and W7 the referenced colour.
When changing a cell in the range to the reference colour the only way to get the count value to update is if I double click the cell and press ENTER.
I did have the script without the volatile, with the volatile, and then with the volatile and TRUE at the end. Neither of these worked in auto updating.
Can someone please help?
Thanks!
I am using a VBA to count cells based on their fill colour. I am using the following script:
Function CountColor(Rng As Range, RngColor As Range) As Integer
Application.Volatile True
Dim Cll As Range
Dim Clr As Long
Clr = RngColor.Range("A1").Interior.Color
For Each Cll In Rng
If Cll.Interior.Color = Clr Then
CountColor = CountColor + 1
End If
Next Cll
End Function
Then in the cell I am using this formula:
=countcolor(B7:Q7,W7)
Where B7:Q7 is the range and W7 the referenced colour.
When changing a cell in the range to the reference colour the only way to get the count value to update is if I double click the cell and press ENTER.
I did have the script without the volatile, with the volatile, and then with the volatile and TRUE at the end. Neither of these worked in auto updating.
Can someone please help?
Thanks!