New Member
Dashboards
Power Query
Power Pivot
Advanced Excel Formulas
Excel Tables
Operations Management
Excel Customer Service
October 26, 2013
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
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
November 8, 2013
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
1 Guest(s)