美文网首页
分别计数不同颜色的单元格

分别计数不同颜色的单元格

作者: 护国寺小学生 | 来源:发表于2019-05-06 21:03 被阅读0次

VBA代码

Function GetColorCount(CountRange As Range, CountColor As Range)

Dim CountColorValue As Integer
Dim TotalCount As Integer
CountColorValue = CountColor.Interior.ColorIndex
Set rCell = CountRange
For Each rCell In CountRange
    If rCell.Interior.ColorIndex = CountColorValue Then
        TotalCount = TotalCount + 1
    End If
Next rCell
GetColorCount = TotalCount
End Function

结果

相关文章

网友评论

      本文标题:分别计数不同颜色的单元格

      本文链接:https://www.haomeiwen.com/subject/jssdoqtx.html