• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Count color

Afarag

Member
Dears,



Please i have i sheet contain more than one columns colored with many colors"Red", "Green", "Black", "Black" etc...
i want to count all cell colored in the column
the attached sheet



Gratefully,
 

Attachments

  • color.xlsx
    52.4 KB · Views: 9
Try the following

To Count: =Sum_color(Range,Color Range,0)
To Sum : =Sum_color(Range,Color Range,1)
Default is Count: =Sum_color(Range,Color Range)

Copy the code into a Code Module in VBA

Code:
Function sum_color(myRange As Range, myColor As Range, Optional myType = 0) As Double
Dim summ As Double
summ = 0
For Each c In myRange
If myType = 1 And c.Interior.Color = myColor.Interior.Color Then summ = summ + c.Text
If myType = 0 And c.Interior.Color = myColor.Interior.Color Then summ = summ + 1
Next
sum_color = summ
End Function
 
@dan_l

okey it's fine

but i have in each row more than one color for this function i want to count more than one color in the row
=ColorFunction($C$1,$A$1:$A$12,FALSE)
 
@Afarag

when you use the Color Function from the Ozgrid then you have mention the Color in the Column $c$1 then it will count the Given Color of C1

Hope it's clear other wise please inform

Thanks
 
yah i get what you explain, but what i ask is if i have in one columns more than one color and i want to count all colored cells, can i use color range or use =Sum(ColorFunction($C$1,$A$1:$A$12,FALSE),ColorFunction($C$2,$A$1:$A$12,FALSE),etc..


Thanks,
 
Last edited:
Back
Top