用颜色计数单元格 [英] count cell with color

查看:78
本文介绍了用颜色计数单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算用特定颜色填充的单元格的数量。

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.

致谢

推荐答案

按照下面的链接说明进行操作,并在链接下面进行提及的更改。

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

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

更改::将链接中给定的脚本更改为以下内容,因为Microsoft脚本使用颜色索引,该索引可能会计算其他颜色的阴影。

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

这篇关于用颜色计数单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆