Run control box on protected sheet

Aretradeser

Board Regular
Joined
Jan 16, 2013
Messages
173
Office Version
  1. 2013
Platform
  1. Windows
On a protected sheet I have a control box. This box control is linked to cell C1. When running this I always get the following error: The cell you are trying to modify is protected and therefore read-only. To modify a protected cell or graph, remove the check-in using the Check Out Sheet command (Review tab, Change group). password may be prompted.
The control box runs the following code:
VBA Code:
Sub Unprotect()
ActiveSheet.Unprotect Password:=“123"
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
The order in which certain events take place determines what ultimately happens (or doesn't). In this case Excel's native Worksheet_Change event handler is most likely triggered first. It detects an attempt (by the control) to change the contents of a cell, before the change event handler of your control is fired, so at that point your worksheet is still protected.
A solution could be to unlock that particular cell. Right click on cell C1, click "Format Cells...", click Protection tab and clear the "Locked" check box.
 
Upvote 0
Solution
The order in which certain events take place determines what ultimately happens (or doesn't). In this case Excel's native Worksheet_Change event handler is most likely triggered first. It detects an attempt (by the control) to change the contents of a cell, before the change event handler of your control is fired, so at that point your worksheet is still protected.
A solution could be to unlock that particular cell. Right click on cell C1, click "Format Cells...", click Protection tab and clear the "Locked" check box.
Thank you
It works perfectly
 
Upvote 0
You are welcome and thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,344
Members
448,570
Latest member
rik81h

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