Autofilter Mode On

  • Hi all -


    I am trying to turn autofilter on for every sheet in the workbook except "Homepage"


    I thought this code would do it

    Code
    For Each ws In wbDest.Sheets
                If ws.Name <> "Homepage" Then
                    ws.AutoFilterMode = True And ws.FilterMode = True
                End If
            Next


    No error messages are received.


    But when I open the file the filter arrows are not visible
    Can you please tell me what I'm doing wrong?
    Thanks
    -marc

  • Re: Autofilter Mode On


    Hi marc,


    Code
    Private Sub Workbook_Open()
    For Each ws In wbDest.Sheets
        If ws.Name <> "Homepage" Then
            ws.Range("A1").AutoFilter
        End If
    Next
        
    End Sub


    Assuming all of your filters are in row 1



    Bill

  • Re: Autofilter Mode On



    If Autofiltermode is already true then your code will remove the autofilter.


    Try,


    [vba]For Each ws In wbDest.Worksheets
    If ws.Name <> "Homepage" And ws.AutoFilterMode = False Then ws.[a1].AutoFilter
    Next[/vba]


    HTH

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!