View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Anders Silven Anders Silven is offline
external usenet poster
 
Posts: 25
Default On Open/On Close

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


"Jeff" skrev i meddelandet
...
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?