Macro/VBA to filter and unfilter same cell in multiple sheets

krodriguez

Board Regular
Joined
Jul 11, 2012
Messages
119
Hello - I have multiple sheets where I want to apply a filter and unfiltered, the location for the filter is the same across all sheets and range is the same BW8:BW400. I recorded a macro for three of the sheets to select the filter and looks like this (see below) but is there a way to consolidate all sheets in 1 statement rather than listed 1 by 1 and also to unfilter all sheets

Sub filters_detail_PLs()


ActiveSheet.Range("$BW$8:$BW$34").AutoFilter Field:=1, Criteria1:="1"
Sheets("RLN-Red Rev").Select
ActiveSheet.Range("$BW$8:$BW$386").AutoFilter Field:=1, Criteria1:="1"
Sheets("RLN-COGS").Select
ActiveSheet.Range("$BW$8:$BW$386").AutoFilter Field:=1, Criteria1:="1"
Sheets("RLN-Logistics").Select

End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Something like
Code:
Sub FlterShts()
   Dim Ws As Worksheet
   For Each Ws In Sheets(Array("RLN-Red Rev", "RLN-COGS", "RLN-Logistics"))
      If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
      Ws.Range("BW8:BW400").AutoFilter 1, "1"
   Next Ws
End Sub
 
Upvote 0
Like
Code:
Sub UnFlterShts()
   Dim Ws As Worksheet
   For Each Ws In Sheets(Array("RLN-Red Rev", "RLN-COGS", "RLN-Logistics"))
      If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
   Next Ws
End Sub
 
Upvote 0
Awesome thanks for your help on this subject and the other VBA you help me out! have a great weekend!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,685
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top