LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default AutoFilter on one sheet filters same on other sheets?

Hello all,

Three of my sheets in my workbook are almost identical, just slightly different data, with AutoFilter turned on in all three sheets.
I have it set up so that when I select a criteria from the AutoFilter drop-down on one of the sheets, the other
2 sheets are AutoFiltered the same way. I did this by creating the following sub procedu

Sub SyncAutoFilters(pstrW1 As String, pstrW2 As String, pstrW3 As String)
Dim w1 As Worksheet
Dim w2 As Worksheet
Dim w3 As Worksheet

Dim pintFltrField As Integer
Dim pstrFltrRng As String
Dim pstrFltrCriteria As String
Dim pintIndex As Integer
Dim pintTest As Integer

Set w1 = Worksheets(pstrW1)
Set w2 = Worksheets(pstrW2)
Set w3 = Worksheets(pstrW3)

pintTest = 0

With w1.AutoFilter
pstrFltrRng = .Range.Address
For pintIndex = 1 To .Filters.Count
If .Filters.Item(pintIndex).On Then
pintFltrField = pintIndex
pstrFltrCriteria = .Filters.Item(pintIndex).Criteria1
pintTest = pintTest + 1
End If
Next
End With

If pintTest = 0 Then
w2.Range(pstrFltrRng).AutoFilter
w3.Range(pstrFltrRng).AutoFilter
Else
w2.Range(pstrFltrRng).AutoFilter pintFltrField, pstrFltrCriteria
w3.Range(pstrFltrRng).AutoFilter pintFltrField, pstrFltrCriteria
End If
End Sub

And then placing one of the following sub calls in the three sheets Deactivate event procedu

SyncAutoFilters "RawData", "RawDataRP", "RawDataTB"
SyncAutoFilters "RawDataTB", "RawData", "RawDataRP"
SyncAutoFilters "RawDataRP", "RawData", "RawDataTB"

The problem is that even if there is no change in the AutoFilter, the SyncAutoFilters sub is still called and there and be a slight
hesitation.

Now also, if I select no filters but leave the auto filter turned on (showing all data) in one of the sheets, it appears to shut off
the AutoFilters in the other two sheets. Moving from the first sheet to the second is no problem because at that point they are all
still on and that is where they are shut off. But if I move from the second to the third, it looks like 2 are shut off and I get an
error.

First is there any way to test to see if the AutoFilter has even been changed before calling the sub? That way I won't get the
slight hesitation EVERY TIME I CHANGE SHEETS. I can handle the hesitation if there is a change in one of the AutoFilters, but
having to deal with it every single time will be quite annoying.

Second, how can I prevent it from completely shutting off the other 2 AutoFilters if I select no filters on the first one, so I
won't get the error when moving from the 2nd to the 3rd sheet?

Thanks for any help anyone can provide,

Conan Kelly



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to link filters in two different sheets? sunny123 Excel Discussion (Misc queries) 0 May 27th 09 07:55 PM
how to link filters in two different sheets? sunny123 Excel Discussion (Misc queries) 0 May 27th 09 05:19 PM
Filters using multiple sheets Scott A Excel Worksheet Functions 0 January 23rd 08 03:07 AM
How do I update filters when using Autofilter? SunGod_69 Excel Worksheet Functions 3 July 25th 06 06:53 AM
Turn ON Autofilter Filters dcHill Excel Programming 1 June 16th 05 07:53 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"