View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rick[_13_] Rick[_13_] is offline
external usenet poster
 
Posts: 18
Default Macro For Filtering on Multiple Sheets

Hi Jason,

Maybe this will get you started. I don't work with auto
filters a lot, but I found something that worked, with a
little experimentation. You can modify this to suit.
Also check the internet for more.

Note this works only with some conditions. It fails if
the criteria is (all) or (top10) etc. And it fails in
other cases too with other combinations. I think there's
a lot more work that has to be done with this....

Sub FourSheetAutoFilters()
Dim S1 As Worksheet: Dim S2 As Worksheet
Dim S3 As Worksheet: Dim S4 As Worksheet
Set S1 = Sheets(1): Set S2 = Sheets(2)
Set S3 = Sheets(3): Set S4 = Sheets(4)

If S1.AutoFilter.Filters(1).Criteria1 = "=Bill" Then
S2.Range("A1").AutoFilter Field:=1, Criteria1:="Bill"
S3.Range("A1").AutoFilter Field:=1, Criteria1:="Bill"
S4.Range("A1").AutoFilter Field:=1, Criteria1:="Bill"
Else
MsgBox "Not Bill"
End If
End Sub

If I find out more and better solutions, I'll let you
know. Meanwhile, let us know how you're doing with this.
Maybe you've figured it out and can share it with us. :)

Rick

-----Original Message-----
Hi,

I have a workbook that has four sheets that contain the
exact same formats (i.e. column headings, range areas,
etc.). The sheets do cover different time periods and
thus the data in each sheet is unique. Currently I have
filters applied on each sheet. Could anyone help me with
a macro that would allow the filtering criteria which is
selected in the first sheet to automatically apply to not
only the first sheet, but also each of the other sheets
as well. Therefore, I would be controlling the filtering
criteria for all four sheets from the criteria selected
on the first sheet. Any suggestions greatly
appreciated. Thanks.

Jason
.