Hi - I am trying to autofilter a field and delete the rows based on the filter, but if one of the criteria in my autofilter brings no data, i want to ignore and move on to the next filter criteria. Currently, my macro stops. Please help!
Sheets("Inventory Status").Activate
Application.DisplayAlerts = True
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:= _
"=*crate*", Operator:=xlOr, Criteria2:="=*probe case*"
ActiveSheet.ListObjects("Table1").DataBodyRange.Delete
ActiveSheet.ShowAllData
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=3, Criteria1:= _
"=*rep*", Operator:=xlOr, Criteria2:="=*con*"
ActiveSheet.ListObjects("Table1").DataBodyRange.Delete
ActiveSheet.ShowAllData
Regards,
Meththini
What do you mean by "my macro stops"? Any macro should stop sometime...
You can check if the table has more than 1 visible cell:
VisibleCellsCount=ActiveSheet.ListObjects(“Table1”).Range.Columns(1).Cells.SpecialCells(xlCellTypeVisible).Count
If VisibleCellsCount>1 Then...
Catalin