View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Rech[_2_] Jim Rech[_2_] is offline
external usenet poster
 
Posts: 533
Default Refresh - Value not refresh (URGENT)

Try adding

Application.Volatile

after the Dims.

Function CountColor(Rng As Range, RngColor As Range) As Integer
Dim Cll As Range
Dim Clr As Long
Application.Volatile
Clr = RngColor.Range("A1").Interior.Color
For Each Cll In Rng
If Cll.Interior.Color = Clr Then CountColor = CountColor + 1
Next Cll
End Function

--
Jim
"RKS" wrote in message
...
| Hi,
| I am counting the cell which background color is red. and each cell i m
| useing conditional formate if value less than target it means cell
background
| color is red other wise its normal. my purpose is count how many task is
| pending. so i can use function colorcount() as:
|
| Function CountColor(Rng As Range, RngColor As Range) As Integer
| 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
|
| and in cell D1 I can use fuction =countcolor(A2:A20,A1)
| A1 = BACKGROUND COLOR WHICH WE WANT COUNT
|
| ITS WORKING FINE BUT PROBLEM IS WHEN CHANGE BACKGROUND COLOR IN CELL, D1
| VALUE IS NOT CHANGE AUTOMATICALLY. ITS CHANGE WHEN I SELECT D1 CELL, PRESS
F2
| AND ENTER.
|
| PLEASE TELL ME WHAT I CAN DO SO VALUE CHANGE AUTOMATICALLY
| THANKS IN ADVANCE
| RKS
|
|