0

I have a range contains different contents with different colors. I want to count the cells with the same font color in it. how can I do ? regards

2
  • 1
    well that depends, are the colors due to conditional formatting? Feb 12, 2018 at 18:39
  • Yeah it can consists, if I prefer use conditional formatting ,could u please write it how?
    – Superstar
    Feb 13, 2018 at 17:34

1 Answer 1

0

Here is some Visual Basic code that accomplishes this task. Found it on this site.

Public Function CountColour(pRange1 As Range, pRange2 As Range) As Double
Application.Volatile
Dim rng As Range
For Each rng In pRange1
    If rng.Font.Color = pRange2.Font.Color Then
        CountColour = CountColour + 1
    End If
Next
End Function

To create the CountColour function, press ALT-F11, then Insert->Module, and write the above function in that window and save it. To use the function, use this syntax on the cell where you want your data displayed: =CountColour(XX:YY,ZZ) where XX:YY represents the cell range you want to count, and ZZ being a cell whose colour you want to count in the given range.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .