Santosh Kumar Ghosh
Santosh Kumar Ghosh

Reputation: 29

count cell with color

I want to count number of cell filled with specific color.

For ex. Few cell are red, few are green few are yellow.

Now I want to count total red/green/yellow.

Is there any idea how could I apply it over merged cell also.

A prompt response will be appreciated.

Regards.

enter image description here

Upvotes: 1

Views: 1398

Answers (1)

ZerosAndOnes
ZerosAndOnes

Reputation: 1093

Follow the instructions on the link below with the mentioned change below the link.

https://support.microsoft.com/en-us/kb/2815384

Change: Change the script given in the link to the following, as the script from microsoft uses color index which may count other shades of a color.

Function CountColor(range_data As range, criteria As range) As Long
    Dim datax As range
    Dim xcolor As Long
    xcolor = criteria.Interior.color
    For Each datax In range_data
        If datax.Interior.color = xcolor Then
           CountColor = CountColor + 1
        End If
    Next datax
End Function

Upvotes: 3

Related Questions