• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Filter Macro won't run on hidden sheet

cacos

Member
Hi everyone!


I'm having an issue recreating a code I picked up from somewhere in the web. What it does is filter a table according to certain criteria, and there's a 2nd sub that restores all the information.


The problem comes when I hide the sheet that has the data, and macros don't work.


Here's the code

[pre]
Code:
Sub Macro1()
'
' Macro1 Macro
'

Sheet1.Select
Range("B8").Select
Selection.CurrentRegion.Select
Range("B8:H30000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("B3:H4"), Unique:=False
Range("A1").Select
End Sub
Sub Macro2()
'
' Macro2 Macro
'

'
Sheet1.Select
ActiveSheet.ShowAllData
End Sub
[/pre]

How can I get it to run with Sheet1 hidden?


Thanks!
 
Hi cacos,


What you can do is; first unhide the sheet1 then do the filtering and sorting operation and then again unhide sheet1. By doing this..your code would be:


Sub Macro1()

'

' Macro1 Macro

'


If Sheet1.Visible = False Then


Sheet1.Visible = xlSheetVisible


End If


Sheet1.Select

Range("B8").Select

Selection.CurrentRegion.Select

Range("B8:H30000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _

Range("B3:H4"), Unique:=False

Range("A1").Select


Sheet1.Visible = xlSheetHidden


End Sub


I have not tested the code. In case of any issue, please consider uploading a sample file.


Kaushik
 
Back
Top