Protected Worksheet Error when Rows/Objects are hidden

learn2vba

New Member
Joined
Jun 11, 2020
Messages
10
Scenario:

Worsheet is protected. Only Forms and Activex Controls can be accessed.

There hidden rows and objects that will be unhidden/enabled when certain options are selected.

The script runs perfectly when worksheet is unprotected but gives errors when protected.



Please help
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,651
Office Version
  1. 365
Platform
  1. Windows
The script runs perfectly when worksheet is unprotected but gives errors when protected.
You need to add to your VBA to unprotect the sheet before you try doing anything to it, and then have it re-protect at the end.
So the steps of your VBA code are:
1. Unprotect sheet
2. Perform steps
3. Protect sheet

See here for how to add that code: Protect and UnProtect Worksheets in Excel VBA - ANALYSISTABS - Innovating Awesome Tools for Data Analysis!
Note you do not need a separate procedure to do these steps. You can simply add the lines of code at the top and bottom of your existing code.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,651
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,617
Messages
5,625,883
Members
416,141
Latest member
Bartek9q

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
Top