Linking Filters

A

Ange

If I have a workbook with say five worksheets all containing the same
columns of data, just different values, with row A of each worksheet having
an auto filters... is there any way to link the auto filters across all five
sheets? so that if i filtered on say "Name" in Sheet one.. the same filter
will be applied to the "Name" column across all sheets?

Cheers
 
J

jan

Ange,

You can try something like this:

Sub FiltersOverSheets()
Dim flt As Filter
Dim sh As Worksheet
Dim shD As Worksheet
Dim i As Integer
Set sh = ActiveSheet
For Each shD In ThisWorkbook.Sheets
If StrComp(sh.Name, shD.Name, vbTextCompare) <> 0 Then
If shD.AutoFilterMode Then
For Each flt In sh.AutoFilter.Filters
i = i + 1
If flt.On = True Then
If flt.Operator <> 0 Then
shD.UsedRange.AutoFilter i, flt.Criteria1,
flt.Operator, flt.Criteria2
Else
shD.UsedRange.AutoFilter i, flt.Criteria1
End If
Else
shD.UsedRange.AutoFilter i
End If
Next
End If
End If
Next
End Sub

What it should do: apply the filter on the activesheet to the filters on the
other sheets.
You can have a button on a commandbar that will call this macro.

Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top