gpt4 book ai didi

excel - "Unable to get the Countif property of the Worksheetfunction class"错误

转载 作者:行者123 更新时间:2023-12-03 00:50:17 25 4
gpt4 key购买 nike

使用此代码时出现“无法获取 Worksheetfunction 类的 Countif 属性”错误

    Windows("usertemp.xls").Activate
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AO$18695").AutoFilter Field:=14, Criteria1:=Array( _
"28", "BE", "CH", "DE", "FR", "JP", "NL"), Operator:=xlFilterValues
Dim Impats As Integer
Impats = Application.WorksheetFunction.CountIf(Range("AL:AL").SpecialCells(xlCellTypeVisible), "I")
MsgBox Impats

最佳答案

CounIf 不接受多区域范围。您需要循环区域:

Dim impats As Long, r As Range
For Each r In Range("AL:AL").SpecialCells(xlCellTypeVisible).Areas
impats = impats + WorksheetFunction.CountIf(r, "I")
Next

关于excel - "Unable to get the Countif property of the Worksheetfunction class"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42703316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com