Hi Guys, I am wondering how can I count different color condition color cells?
I am currently using this UDF,
With the formula: =ColorFunction($D$1,$D$1:$D$10).
However, this code count the entire conditioned color cells that I have. What I want is for the code to count two different colors within the same column range (like B1:B10). For example, I have 3 red color cells in range B1:B10 and 7 green color cells in range B1:B10. So, I want it to count 3 and 7 seperately rather than giving me the total of 10.
Please help thanks!
Important Note: As it is a conditioned coloring, there is no fixed coloring as to which cell will have the red or green since it is based on conditions.
One last time, I am using Excel 2007.
I am currently using this UDF,
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
With the formula: =ColorFunction($D$1,$D$1:$D$10).
However, this code count the entire conditioned color cells that I have. What I want is for the code to count two different colors within the same column range (like B1:B10). For example, I have 3 red color cells in range B1:B10 and 7 green color cells in range B1:B10. So, I want it to count 3 and 7 seperately rather than giving me the total of 10.
Please help thanks!
Important Note: As it is a conditioned coloring, there is no fixed coloring as to which cell will have the red or green since it is based on conditions.
One last time, I am using Excel 2007.