PDA

View Full Version : [SOLVED] Option Button in a Protected Worksheet



jammer6_9
07-13-2009, 12:13 AM
I have created 255 Option Buttons group in to 3 (YES, NO, N/A). Working fine IF Worksheet is unprotected BUT do not work if sheets is protected even if Option Button Properties Locked option is unchecked. Is there any way to write a macro during Click Event to unprotect sheet then protect it again? Option Button used is from FORMS not in the Visual Basic Controll Toolbox.

JimmyTheHand
07-13-2009, 12:28 AM
Try


Private Sub OptionButton1_Click()
ActiveSheet.Unprotect Password:="abc"
'rest
'of
'code
ActiveSheet.Protect Password:="abc", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

jammer6_9
07-13-2009, 01:09 AM
Thanks for the quick response but it seems it does not work. I have attached a sample workbook with a password of "abc"... In here even I will write the code that you provided, same scenario is coming up wherein everytime you click on those option button when the sheet is protected, still same error comes.


Try


Private Sub OptionButton1_Click()
ActiveSheet.Unprotect Password:="abc"
'rest
'of
'code
ActiveSheet.Protect Password:="abc", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

jammer6_9
07-13-2009, 08:08 AM
Found it:

It was due to option buttons are linked to the cell that is locked.

I had checked the box to allow editing of objects in that cell after protection. Once I removed that check, it locked as it should.

Thread is solved.