On Open/On Close

  • Thread starter Thread starter Jeff
  • Start date Start date
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?
 
Jeff,

You can use

Worksheets("You Sheet").Activate

at the begging of your macro and when you close.


HTH


Charle
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top