[英]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.