Auto-hiding sheets AND charts [code needs a tweak]

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
Hi All,

The code below works fine, apart from it will not hide charts, only sheets.

Upon closing, I need to hide everything (sheet and charts) and just leave "LOCKED" on display. When it opens, I need to see everything except "LOCKED"

Could anyone tell me the most efficient way to amend the code below to accomodate this please?

Code:
Option Explicit

Sub Auto_close()
Dim wsSheet As Worksheet

Application.ScreenUpdating = False

For Each wsSheet In ThisWorkbook.Worksheets
    If wsSheet.Name = "LOCKED" Then
     wsSheet.Visible = xlSheetVisible
    Else
     wsSheet.Visible = xlSheetVeryHidden
    End If
Next wsSheet
    ActiveWorkbook.Save

Application.ScreenUpdating = True

End Sub

'/////////////////////////////////

Sub Auto_open()

Application.ScreenUpdating = False
    
   Dim wsSheet As Worksheet
For Each wsSheet In ThisWorkbook.Worksheets
    If wsSheet.Name <> "LOCKED" Then
     wsSheet.Visible = xlSheetVisible
    End If
Next wsSheet

Sheets("LOCKED").Visible = xlSheetVeryHidden

  Application.ScreenUpdating = True
  
End Sub


Suggestions appreciated !
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try looping around ThisWorkbook.Sheets instead of ThisWorkbook.Worksheets. You will need to declare wsSheet as Object.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top