【发布时间】:2018-10-04 02:28:18
【问题描述】:
我想在状态跟踪器上使用以下函数“CountCcolor()”。我的目的是能够使用该函数在可见单元格的单个列范围内查找有多少以特定颜色突出显示,例如绿色。
Function CountCcolor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long
' The next one-liner does not work. Without it, it selects visible and hidden cells. I only want it to select visible cells:
range_data = Selection.SpecialCells(xlCellTypeVisible).Select
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function
提前感谢您的帮助!
【问题讨论】:
标签: vba range excel-2010 cell visible