“Unable to get the Countif property of the Worksheetfunction class” error

后端 未结 2 908
萌比男神i
萌比男神i 2021-01-21 14:07

I get a \"Unable to get the Countif property of the Worksheetfunction class\" error when using this code

    Windows(\"usertemp.xls\").Activate
Selection.AutoFil         


        
2条回答
  •  心在旅途
    2021-01-21 14:29

    CounIf does not accept a multi-area range. You need to loop over the 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
    

提交回复
热议问题