Excel action when closing workbook

ziadh15

New Member
Joined
May 13, 2016
Messages
33
Hello

I am new to VBA but did a lot of research and a lot of readings in order to create a VBA to my employer.
I have written the code but having some small bugs that you guys might be helpful.

Project:
When you first open my excel sheet, only three pages will be visible( Sheet 1,2 & 11)
I have total of 11 pages; so the rest are hidden.
On Sheet11, I have a command button that will open up a userform.

In this userform, user will enter a number, and based on that it will show the associated hidden file.

Issue:
When I close the document, click on "Save As" and re-open the file, it will revert back to it's original format i.e: Only the first three main sheets are open.

Below is my code that I put inside the workbook. Basically telling it to hide everything except my 3 main sheets.

Code:
Private Sub Workbook_Open()
Dim wsSheet As Worksheet
Application.ScreenUpdating = False
    For Each wsSheet In Worksheets
       If wsSheet.Name = "Start" Or _
          wsSheet.Name = "Rev Log" Or _
          wsSheet.Name = "Instructions" Then
            wsSheet.Visible = True
            Else: wsSheet.Visible = False
                   End If
    Next wsSheet
Application.ScreenUpdating = True
End Sub

How to fix this?

Thanks

Ziad
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi there - you've mentioned what happens so far, but, you've missed out what your actually looking to achieve instead?
 
Upvote 0

Forum statistics

Threads
1,215,945
Messages
6,127,856
Members
449,411
Latest member
adunn_23

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