2017-03-09 158 views
2

私は「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 
+1

#FunFacts:

はこれを試してみてください! –

答えて

1

CounIfこのコードを使用してマルチを受け付けていない場合、エラー「WorksheetfunctionクラスのCOUNTIFのプロパティを取得できません」を取得エリア範囲。あなたはAreas上でループする必要があります。

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

これはうまくいった - ありがとう! – aoswald

2

SpecialCells(xlCellTypeVisible)はとりとめのない範囲を作成し、Countifはとりとめのない範囲で素晴らしいプレーしません。

ループを使用して各条件をループし、Countifsを追加する必要があります。そのエラーメッセージがされてめちゃめちゃアップ - `WorksheetFunction.CountIf`はプロパティではありません。

Dim arr() as variant 
Dim arrPart as variant 
arr = Array("28", "BE", "CH", "DE", "FR", "JP", "NL") 

Dim Impats As Integer 

For Each arrPart in arr 
    Impats = Impats + Application.WorksheetFunction.CountIfs(ActiveSheet.Range("AL:AL"), "I",ActiveSheet.Range("N:N"),arrPart) 
Next arrPart 
MsgBox Impats 
関連する問題