+ Reply to Thread
Results 1 to 4 of 4

Autofilter for multiple sheets

  1. #1
    Agustus
    Guest

    Autofilter for multiple sheets

    Hi,

    I have a macro below to turn the autofilter "on" for multiple selected
    sheets but it generated error. Please advise.

    Sub auto_filter_all_sheets()
    Dim ws As Worksheet
    Application.ScreenUpdating = False

    sAddress = Selection.Address
    For Each ws In ActiveWindow.SelectedSheets
    ws.Activate
    If sAddress > "" Then ws.Range(sAddress).Select
    Selection.AutoFilter
    Next ws
    Application.ScreenUpdating = True
    End Sub

    TIA.


  2. #2
    Tom Ogilvy
    Guest

    Re: Autofilter for multiple sheets

    Sub auto_filter_all_sheets()
    Dim ws As Worksheet
    Application.ScreenUpdating = False

    if selection.Rows.count < 3 then exit sub
    sAddress = Selection.Address
    For Each ws In ActiveWindow.SelectedSheets
    ws.Range(sAddress).AutoFilter
    Next ws
    Application.ScreenUpdating = True
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Agustus" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have a macro below to turn the autofilter "on" for multiple selected
    > sheets but it generated error. Please advise.
    >
    > Sub auto_filter_all_sheets()
    > Dim ws As Worksheet
    > Application.ScreenUpdating = False
    >
    > sAddress = Selection.Address
    > For Each ws In ActiveWindow.SelectedSheets
    > ws.Activate
    > If sAddress > "" Then ws.Range(sAddress).Select
    > Selection.AutoFilter
    > Next ws
    > Application.ScreenUpdating = True
    > End Sub
    >
    > TIA.
    >




  3. #3

    Re: Autofilter for multiple sheets

    Hi Tom,
    think Tia needs to return the filter,
    assumed the autofilter is already checked up !,
    but don't know why she needs to achieve for ?
    perhaps :
    ws.Range(sAddress).AutoFilter field:="Shomething"
    if only turned on or checked up the autofilter, i think no need
    do it by automation !?, it wil be more complicating if do it by
    automation!
    is that r8?

    Please reply ..., just guess

    Rgds,
    halim

    Tom Ogilvy menuliskan:
    > Sub auto_filter_all_sheets()
    > Dim ws As Worksheet
    > Application.ScreenUpdating = False
    >
    > if selection.Rows.count < 3 then exit sub
    > sAddress = Selection.Address
    > For Each ws In ActiveWindow.SelectedSheets
    > ws.Range(sAddress).AutoFilter
    > Next ws
    > Application.ScreenUpdating = True
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Agustus" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I have a macro below to turn the autofilter "on" for multiple selected
    > > sheets but it generated error. Please advise.
    > >
    > > Sub auto_filter_all_sheets()
    > > Dim ws As Worksheet
    > > Application.ScreenUpdating = False
    > >
    > > sAddress = Selection.Address
    > > For Each ws In ActiveWindow.SelectedSheets
    > > ws.Activate
    > > If sAddress > "" Then ws.Range(sAddress).Select
    > > Selection.AutoFilter
    > > Next ws
    > > Application.ScreenUpdating = True
    > > End Sub
    > >
    > > TIA.
    > >



  4. #4
    Agustus
    Guest

    Re: Autofilter for multiple sheets

    Thank very much, Tom.. It works. The reason is that I have 10+ sheets
    and need to turn the filter on for each sheet. With multiple sheets
    selected, the menu does not allow autofilter option.

    Best regards,
    Agustus


    [email protected] wrote:
    > Hi Tom,
    > think Tia needs to return the filter,
    > assumed the autofilter is already checked up !,
    > but don't know why she needs to achieve for ?
    > perhaps :
    > ws.Range(sAddress).AutoFilter field:="Shomething"
    > if only turned on or checked up the autofilter, i think no need
    > do it by automation !?, it wil be more complicating if do it by
    > automation!
    > is that r8?
    >
    > Please reply ..., just guess
    >
    > Rgds,
    > halim
    >
    > Tom Ogilvy menuliskan:
    > > Sub auto_filter_all_sheets()
    > > Dim ws As Worksheet
    > > Application.ScreenUpdating = False
    > >
    > > if selection.Rows.count < 3 then exit sub
    > > sAddress = Selection.Address
    > > For Each ws In ActiveWindow.SelectedSheets
    > > ws.Range(sAddress).AutoFilter
    > > Next ws
    > > Application.ScreenUpdating = True
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Agustus" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi,
    > > >
    > > > I have a macro below to turn the autofilter "on" for multiple selected
    > > > sheets but it generated error. Please advise.
    > > >
    > > > Sub auto_filter_all_sheets()
    > > > Dim ws As Worksheet
    > > > Application.ScreenUpdating = False
    > > >
    > > > sAddress = Selection.Address
    > > > For Each ws In ActiveWindow.SelectedSheets
    > > > ws.Activate
    > > > If sAddress > "" Then ws.Range(sAddress).Select
    > > > Selection.AutoFilter
    > > > Next ws
    > > > Application.ScreenUpdating = True
    > > > End Sub
    > > >
    > > > TIA.
    > > >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1