【发布时间】:2014-08-08 23:27:03
【问题描述】:
我正在尝试计算包含“更改”一词的字段的数量,但这是在过滤列表上执行的,因此我使用 SpecialCells(xlCellTypeVisible) 属性来测试它们是否是过滤的一部分列表。示例代码如下所示:
aWorkbook.Worksheets("Sheet1").Cells(22, 10).Formula = WorksheetFunction.CountIf(Range(Cells(3, 10), Cells(20, 10)).SpecialCells(xlCellTypeVisible), "Change")
但我收到以下错误:
Run-time error'1004': Unable to get the CountIf property of the WorksheetFunction class
以下使用 Sum 的代码按预期工作,但我觉得很奇怪
aWorkbook.Worksheets("Sheet1").Cells(22, 7).Formula = WorksheetFunction.Sum(Range(Cells(3, 7), Cells(20, 7)).SpecialCells(xlCellTypeVisible))
【问题讨论】: