Macros not functioning due to protected sheet

nathans excel

New Member
Joined
Nov 15, 2017
Messages
3
Good day, created a fine looking spread sheet loaded with functionality ... one of them being some command buttons which reveal some hidden rows upon each "click" ... locked all the cells I didn't want people to mess around with and protected the sheet ...

in "protected sheet" mode the button and macros are unresponsive and yields ... runtime error 1004 .. .unable to set the hidden property of the range class

when the sheet is unprotected ... works like it is supposed to.

So the conclusion is the protection has it locked down ...

is there some code I can add to the "worksheet" to let the macros/button functionality still do its job?

Nathan
Excel 2013
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Maybe try this:

Example to Protect Worksheet

Code:
[COLOR=#00A0C8][FONT=inherit]Sub sbProtectSheet()
[/FONT][/COLOR]ActiveSheet.Protect "password", True, True 
[COLOR=#00A0C8][FONT=inherit]End Sub[/FONT][/COLOR]

Example to UnProtect Worksheet

Code:
[COLOR=#00A0C8][FONT=inherit]Sub sbUnProtectSheet()
[/FONT][/COLOR]ActiveSheet.Unprotect "password"
 [COLOR=#00A0C8][FONT=inherit]End Sub[/FONT][/COLOR]
 
Upvote 0
Can you just turn off and then on the protection at the start and end of the macro?

Code:
[COLOR=#333333][FONT=Courier]sheet("yoursheetname").Unprotect Password:="yourPassword"

'your code here

[/FONT][/COLOR][COLOR=#333333][FONT=Courier]sheet("yoursheetname").Protect Password:="yourPassword"[/FONT][/COLOR][COLOR=#333333][FONT=Courier]
[/FONT][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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