count cell with color

时光毁灭记忆、已成空白 提交于 2019-12-31 05:28:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!