3x Checkboxes - Hide/Unhide sheet

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi there,

I have 3x Form Check Boxes. If any of them are ticked, I would like sheet "Dairy" to be visible. If none of them are ticked, sheet "Dairy" should be hidden.

I have linked the 3x check box references to cells P1, P2 and P3. In P4 I have the following formula =IF(OR(P1,P2,P3=TRUE),TRUE,FALSE)

I then tried entering this VBA code under my current worksheet. However, it's not working. Is there anyway to get this working? I would like to avoid using an ActiveX Check Box if possible. Thanks!

Code:
Private Sub Worksheet_Calculate()
If [P4] = True Then
Sheets("Dairy").Visible = False
Else
Sheets("Dairy").Visible = True
End Sub
 
Yes, I copied your code and replaced it.
It works if "G2" is Unprotected and "Beef" is Protected, but it won't work if both sheets are Protected.
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Yes, I copied your code and replaced it.
It works if "G2" is Unprotected and "Beef" is Protected, but it won't work if both sheets are Protected.

Try this

Code:
Sub Beef()
    activesheet.Unprotect
    Sheets("Beef").Unprotect
    Sheets("Beef").Visible = False
    If [Q1] Then Sheets("Beef").Visible = True
    Sheets("Beef").Protect
    activesheet.Protect
End Sub
 
Upvote 0
Sorry, but I do not understand.
You can tell step-by-step what to do in your file and what you expect in each step.
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

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