excel-vbaautofilter ; Uses and best practices


Autofilter ultimate goal is to provide in the quickest way possible data mining from hundreds or thousands of rows data in order to get the attention in the items we want to focus on. It can receive parameters such as "text/values/colors" and they can be stacked among columns. You may connect up to 2 criteria per column based in logical connectors and sets of rules. Remark: Autofilter works by filtering rows, there is no Autofilter to filter columns (at least not natively).


'To use Autofilter within VBA we need to call with at least the following parameters:

Sheet("MySheet").Range("MyRange").Autofilter Field=(ColumnNumberWithin"MyRange"ToBeFilteredInNumericValue) Criteria1:= "WhatIWantToFilter"

'There are plenty of examples either on the web or here at stackoverflow