• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

No Cells Were Found

Hi,

I am getting this error...

I am trying to autofilter based on the criteria for example
Code:
Sheet18.UsedRange.AutoFilter FIELD:=3, Criteria1:="High"
Set str10 = Sheet18.Range("E2:E" & val1).SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants)
v15 = Application.WorksheetFunction.CountIf(str10, ">4")

Here in the sheet Field 3 don't have High type value for the current week so it has to return 0 if it dont find any criteria based on the value given.

How to return the value if the criteria is not available in the column that we autofilter.
Regards,
sakthi
 
Need some sort of error trap, like this:
Code:
Sheet18.UsedRange.AutoFilter FIELD:=3, Criteria1:="High"
On Error Resume Next
Set str10 = Sheet18.Range("E2:E" & val1).SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants)
On Error GoTo 0
If str10 Is Nothing Then
    v15 = 0
Else
    v15 = Application.WorksheetFunction.CountIf(str10, ">4")
End If
 
Back
Top