I get a \"Unable to get the Countif property of the Worksheetfunction class\" error when using this code
Windows(\"usertemp.xls\").Activate
Selection.AutoFil
The SpecialCells(xlCellTypeVisible)
will create a disjointed range and Countif
does not play nice with disjointed ranges.
You will need to use a loop to loop through each criteria and add the Countifs
together.
Try this:
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