• 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.

Hide multiple sheets

Please help me correct this

Code:
    Sub VeryHiddenSheet()
         ThisWorkbook.Sheets("Sheet1", "Sheet5", "Sheet6", "Sheet7", "Sheet8", "Sheet9").Visible = xlVeryHidden
    End Sub
 
Try this code
Code:
Sub VeryHiddenSheet()
    Dim e
  
    For Each e In Array("Sheet1", "Sheet5", "Sheet6", "Sheet7", "Sheet8", "Sheet9")
        ThisWorkbook.Sheets(e).Visible = xlVeryHidden
    Next e
End Sub
Thank you, However - I get error message it says - Subscription out of range
 
Code:
    Sub VeryHiddenSheet1()
        Sheet1.Visible = xlSheetVeryHidden
        Sheet5.Visible = xlSheetVeryHidden
        Sheet6.Visible = xlSheetVeryHidden
        Sheet7.Visible = xlSheetVeryHidden
        Sheet8.Visible = xlSheetVeryHidden
        Sheet9.Visible = xlSheetVeryHidden
        Sheet2.Activate
    End Sub
this works
 

YasserKhalil

Well-Known Member
No problem at all
You can use the worksheet code names in that way
Code:
Sub VeryHiddenSheet()
    Dim e
   
    For Each e In Array(Sheet1, Sheet5, Sheet6, Sheet7, Sheet8, Sheet9)
        e.Visible = xlVeryHidden
    Next e
End Sub
 
Top