AutoFilter

If you use the Selection.AutoFilter Filter:=2 then it will reset just column 2, if you use Selection.AutoFilter then it will reset on all columns and will remove the AutoFilter completely.



Worksheets("Data").Select 
Worksheets("Data").AutoFilterMode = True
Range("A2").AutoFilter
Range("A2").AutoFilter Field:=3, Criteria1:="filter"



Range("B2").Select 

The following line adds the autofilter to the currentregion of the active cell.

ActiveCell.AutoFilter 

ActiveCell.AutoFilter Criteria="String" 
ActiveCell.AutoFilter Field:=1, Criteria:=">10/07/2004", Operator:=xlAnd, Criteria2:="<16/07/2002"

Range("Database").Select 


Removing all existing filters

ActiveSheet.ShowAllData 

The above line causes run-time error if filtering is not applied - TEST THIS

On Error Resume Next 
ActiveSheet.ShowAllData






© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext