Code

Lambada

Board Regular
Joined
May 10, 2002
Messages
62
How can I make certain sheets on a workbook visible or very hidden based on answer (yes or no) entered on cells AM20,AM21,AM22 on sheet 2.

Examples:

If AM20=YES, Sheet 15 is visible, If NO Sheet 15 is very hidden.

IF AM21=YES, Sheet 1, 9, and 10 are visible, If NO sheets 1,9, and 10 are Very hidden.

Thank you.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi Lambada:

How about using the following little sub for cell AM20 and Sheet 15 ...

Sub yHideSheets()
'Macro by Yogi Anand on Sep-7-2002
If [AM20] = "Yes" Then Worksheets("Sheet5").Visible = True
Worksheets("Sheet5").Visible = xlVeryHidden
End Sub

Does this help? you can extend this for use with value in cell AM21 and Sheets 1,9, and 10.

Regards!

Yogi
 
Upvote 0
Hi Lambada:

Here is what is supposed to happen with the code in my post. You have to have a workbook with at least 5 worksheets. Cell AM20 in Sheet1 is to house "Yes" (without quotes).
Then the following code:

Sub yHideSheets()
'Macro by Yogi Anand on Sep-7-2002
If [A20] = "Yes" Then Worksheets("Sheet5").Visible = True
Worksheets("Sheet5").Visible = xlVeryHidden
End Sub

is to be put in a module (say Module1) of This Workbook.

Then after the code has been put in the right place, and the cell AM20 in Sheet1 houses "Yes" (without quotes"), then on running the code in the sub, the Sheet5 is supposed to become VeryHidden.

I Have tested the code and this indeed does happen.

You may have to check your work step by step to make sure that everything is done correctly.

Regards!

Yogi
 
Upvote 0
Thank you Yogi. The problem is that cell AM20 is on sheet 2. How do I go about changing it to work?
 
Upvote 0
Hi Lambada:

If cell AM20 to be tested is in Sheet2, then change the code to:

Sub yHideSheets()
'Macro by Yogi Anand on Sep-7-2002
If [Sheet2!AM20] = "Yes" Then Worksheets("Sheet5").Visible = True
Worksheets("Sheet5").Visible = xlVeryHidden
End Sub

(By the way, in the earlier code, I had mistyped the cell AM20 as A20)

I hope this helps.

Regards!

Yogi
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,457
Members
448,898
Latest member
drewmorgan128

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