Class AutoFilter (Excel VBA)

The class AutoFilter represents autofiltering for the specified worksheet.

Item

To use a AutoFilter class variable it first needs to be instantiated, for example

Dim afr as AutoFilter
Set afr = ActiveSheet.AutoFilter

The following procedures can be used to set variables of type AutoFilter: ListObject.AutoFilter and Worksheet.AutoFilter.

ApplyFilter

Applies the specified AutoFilter object.

ActiveSheet.AutoFilter.ApplyFilter

FilterMode

Returns True if the worksheet is in the AutoFilter filter mode.

Dim booFilterMode As Boolean
booFilterMode = ActiveSheet.AutoFilter.FilterMode

Filters

Returns a Filters collection that represents all the filters in an autofiltered range.

Dim fltsFilters As Filters
Set fltsFilters = ActiveSheet.AutoFilter.Filters

Range

Returns a Range object that represents the range to which the specified AutoFilter applies.

Dim rngRange As Range
Set rngRange = ActiveSheet.AutoFilter.Range

ShowAllData

Displays all the data returned by the AutoFilter object.

ActiveSheet.AutoFilter.ShowAllData

Sort

Gets the sort column or columns, and sort order for the AutoFilter collection.

Dim srtSort As Sort
Set srtSort = ActiveSheet.AutoFilter.Sort