View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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.