On Open/On Close

J

Jeff

I have three sheets: X, Y, & Z. The only sheet I want
visible when first opened or when closed is sheet X. What
would the VBA code look like to accomplish this?
 
C

Charles

Jeff,

You can use

Worksheets("You Sheet").Activate

at the begging of your macro and when you close.


HTH


Charle
 
A

Anders Silven

One way, Jeff,

In the code module for ThisWorkbook:

'*****
Option Explicit
Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In Me.Worksheets
If wks.Name <> "Sheet1" Then wks.Visible = xlSheetHidden
Next
End Sub
'*****

You may enter the same code in Workbook_Close as well, so the sheets will not be
visible if the workbook is opened with macros disabled.-

HTH
Anders Silven
 
B

Bob Phillips

I replied to your earlier post. What was wrong with that suggestion?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top