L
Legacy 365210
Guest
Hi All
I have code that needs to turn off any filters on 3 sheets before doing some actions, mainly find-replace and copy-paste.
My issue is the code to unfilter only works on the activesheet, I have declared the sheets and tried working through the variable directly (as below) but this just ignores the code for the inactivesheets and runs it on the activesheet (whichever one of the 3 I have open in the backround).
Now obviously I am trying my hardest to avoid the SELECT or ACTIVATE cardinal sins here - so any advice on getting this to check for and unfilter the 3 x sheets without select? Code below
I have code that needs to turn off any filters on 3 sheets before doing some actions, mainly find-replace and copy-paste.
My issue is the code to unfilter only works on the activesheet, I have declared the sheets and tried working through the variable directly (as below) but this just ignores the code for the inactivesheets and runs it on the activesheet (whichever one of the 3 I have open in the backround).
Now obviously I am trying my hardest to avoid the SELECT or ACTIVATE cardinal sins here - so any advice on getting this to check for and unfilter the 3 x sheets without select? Code below
Code:
Dim Pre As Worksheet
Set Pre = Worksheets("Pre")
Dim Post As Worksheet
Set Post = Worksheets("Post")
Dim PrePostCombined As Worksheet
Set PrePostCombined = Worksheets("Pre_Post_Combined")
If (Pre.AutoFilterMode And Pre.FilterMode) Or Pre.FilterMode Then
Pre.ShowAllData
End If
If (Post.AutoFilterMode And Post.FilterMode) Or Post.FilterMode Then
Post.ShowAllData
End If
If (PrePostCombined.AutoFilterMode And PrePostCombined.FilterMode) Or PrePostCombined.FilterMode Then
PrePostCombined.ShowAllData
End If