Hide Worksheet based on value of a cell

mgchurch77

New Member
Joined
Aug 15, 2011
Messages
33
I would like to hide a worksheet named "Validation Summary Page" based on the contents of AE7 of a worksheet named "Report Data". By default the sheet titled "Validation Summary Page" would be hidden and would become unhidden if and when a user enters the number "2" into AE7. If any value other than 2 is entered then "Validation Summary Page" is hidden again.

I would post the code I tried, however I have a feeling that it is so far off the mark that it would be of no use to anyone and would probably only confuse people. Also curious as to where the code should reside. Should it reside at the workbook level, or on the sheet holding the target cell, or on the sheet to be hidden/unhidden? Thanks.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This will go on the "Report Data" sheet
right click the Tab on "Report Data" - Select View Code
Paste the following

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("Validation Summary Page").Visible = Sheets("Report Data").Range("AE7").Value = 2
End Sub

Hope that helps.
 
Upvote 0
Thanks, however it didn't seem to work. Pasted into "Report Data" as you instructed. I also checked the spelling on your code vs. the names of my sheets, good there. Target cell is correct. ?????

In full disclosure, I do have another code running on "Report Data" above the code that you gave me to paste, however it is only hiding rows on the "Report Data" sheet based on the contents of another target cell, and nothing to do with "Validation Summary Page". Not sure if that would have an impact to the code you gave me. Any thoughts?
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

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