ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofilter for multiple sheets (https://www.excelbanter.com/excel-programming/370740-autofilter-multiple-sheets.html)

Agustus

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.


Tom Ogilvy

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" wrote in message
oups.com...
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.




[email protected]

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" wrote in message
oups.com...
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.



Agustus

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


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" wrote in message
oups.com...
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.




All times are GMT +1. The time now is 12:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com