Dougie1
Board Regular
- Joined
- Jul 27, 2007
- Messages
- 212
Hi all -
Using Excel 2007.
Can anyone help me modify the code below?
What it does on workbook close is hide all worksheets except Sheet1 & Sheet2.
I have recently added a Chart, but on close the code leaves it visible along with sheets 1 & 2.
I know it is something to do with the chart not being a worksheet, but am at a loss how to include it in this code. All help gratefully received.
TIA
D
Using Excel 2007.
Can anyone help me modify the code below?
What it does on workbook close is hide all worksheets except Sheet1 & Sheet2.
I have recently added a Chart, but on close the code leaves it visible along with sheets 1 & 2.
I know it is something to do with the chart not being a worksheet, but am at a loss how to include it in this code. All help gratefully received.
TIA
D
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
Application.Calculation = xlAutomatic
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet1" And ws.Name <> "Sheet2" Then ws.Visible = xlSheetVeryHidden
Next ws
End Sub