[英]Excel SpecialCells
我上101课。 尝试计算数据透视表中的颜色。 下面的数字是所有颜色的计数,包括过滤出的颜色。
有没有一种方法只计算正在显示的行?
此方法不起作用:
For Each TCell In CountRange.SpecialCells(xlCellTypeVisible)
问题:正在计算该标题的过滤出的行。
Function CountByColor(CellColor As Range, CountRange As Range)
Application.Volatile
Dim ICol As Integer
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In CountRange.SpecialCells(xlCellTypeVisible)
If ICol = TCell.Interior.ColorIndex Then
CountByColor = CountByColor + 1
End If
Next TCell
End Function
我不是SpecialCells
忠实SpecialCells
因为它们存在一些更新方面的困难。 结果,在测试隐藏行时,我去了老派 ,如下面的代码所示:
Function CountByColor(CellColor As Range, CountRange As Range)
Application.Volatile
Dim ICol As Integer
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In CountRange.Cells
If Not TCell.EntireRow.Hidden And ICol = TCell.Interior.ColorIndex Then
CountByColor = CountByColor + 1
End If
Next
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.