问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/38827792/count-cell-with-color