I have the below code and I get an error when trying to run it I get the error
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
End If
Selection.AutoFilter Field:=95, Criteria1:=Array("ABC", "DEF", "GHI", "JKL"), Operator:=xlFilterValues
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Rows.Count
If ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Rows.Count > 1 Then
ActiveSheet.Range("2:" & ActiveSheet.UsedRange.Rows.Count).SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
End If<strike></strike>
[/FONT]
Run-time error '1004':Autofilter method of Range class failed
<strike>
</strike>
<strike></strike>[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Worksheets("DATA").AutoFilterMode = FalseThis is because after filtering sometimes I have no results.
I would like to have a code that tells to ignore the code if the Autofilter returns no result. I have tryied also including the code On Error Resume Next
Any idea how to do that? Thanks!On Error GoTo 0
</strike>
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
End If
Selection.AutoFilter Field:=95, Criteria1:=Array("ABC", "DEF", "GHI", "JKL"), Operator:=xlFilterValues
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Rows.Count
If ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Rows.Count > 1 Then
ActiveSheet.Range("2:" & ActiveSheet.UsedRange.Rows.Count).SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
End If<strike></strike>
[/FONT]