VBA Code - Hide / Unhide Sheets Macro in Protection Mode

tlc53

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

I have the below macro assigned to a Check Box on sheet "G2". The Check Box is Unlocked.
I would like both sheets "Beef" and "G2" to be protected.
However, the below macro will not run if sheet "G2" is protected (it runs fine with sheet "Beef" protected and sheet "G2" unprotected).
I have tried inserting ActiveSheet.Unprotect ("") and ActiveSheet.Protect("") into the below code but that doesn't work. Does anyone know how I can get this to work with both sheets protected? Thank you

Code:
Sub Beef()
    Sheets("Beef").Visible = False
    If [Q1] Then Sheets("Beef").Visible = True
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,226,113
Messages
6,189,048
Members
453,522
Latest member
Seeker2025

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