How to create a Macro to open and/or hide worksheets

Charles_

New Member
Joined
Dec 12, 2012
Messages
32
Hello,

I have tried searching for this on other threads to no avail.

I am trying to create a Macros where depending on the value of cell A2 (I have a data validation LIST type here), worksheet 1 or worksheet 2 will open.

For example, if the value on worksheet 1 cell A2 = "Yes" then hide worksheet 1 and 3 and open worksheet 2 only

if the value on worksheet 1 cell A2 = "No" then hide worksheet 1 and 2 and open worksheet 3 only.


I do not need to copy and paste any data across - worksheets 1 & 2 are completed

Thanks in advance.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hello,

I have found a solution for this issue by creating a button and defining the below

Private Sub CommandButton1_Click()


Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Visible = False


End Sub

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,633
Messages
6,125,922
Members
449,274
Latest member
mrcsbenson

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