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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

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