FilterMode Property

Microsoft Office Web Components Visual Basic

True if any worksheet rows are currently hidden by AutoFilter criteria. The default value is False. Read-only Boolean.

expression.FilterMode

expression    Required. An expression that returns a Worksheet object.

Remarks

If the AutoFilter drop-down arrows are visible but no rows are currently filtered (all rows are visible), the AutoFilterMode property is True and the FilterMode property is False.

Example

This example turns on the AutoFilter for the range A1:C20, sets filters for columns A and C, and then applies the filters. The FilterMode property returns False until the AutoFilter criteria has been applied to the list.

Sub Apply_AutoFilter()
    Dim afFilters
    Dim afCol1
    Dim afCol3
    
    ' Turn on AutoFilter.
    Spreadsheet1.Worksheets("Sheet1").Range("A1:C20").AutoFilter
    
    ' Set a variable to the AutoFilter object.
    Set afFilters = Spreadsheet1.Worksheets("sheet1").AutoFilter
    
    Set afCol1 = afFilters.Filters(1)
    Set afCol3 = afFilters.Filters(3)
    
    ' Add a criteria that excludes blue from column A.
    afCol1.Criteria.Add "blue"
    
    ' Add a criteria that excludes green from column A.
    afCol1.Criteria.Add "green"
    
    ' Add a criteria that excludes yellow from column c.
    afCol3.Criteria.Add "yellow"
    
    ' At this point, the FilterMode property is False
    ' because the AutoFilter criteria has not been applied.
    MsgBox Spreadsheet1.Worksheets("Sheet1").FilterMode
    
    ' Apply the criteria.
    afFilters.Apply
    
    ' The FilterMode property is now True since you
    ' have hidden several rows in the list.
    MsgBox Spreadsheet1.Worksheets("Sheet1").FilterMode
End Sub