Replace the macro with
Private Sub ProtectionToggle()
ActiveCell.Activate
If ProtectionToggle.Value = True Then
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
End If
End Sub
Juan Pablo
Tks Juan - still a bit confused tho. I'm having trouble attaching your macro to my Option Button from the FORMS menu.
What's the Private bit signify? All my other (recorded) macros kick in with Sub etc. These I can attach to the Option Button without any problems, but with yours I'm having trouble.
Cheers, Riki
Ok, i think you need to elaborate a little bit more on what you're doing / trying to do.
For what i understood, you have (should, i guess) two option buttons, one that is "Protect sheet" and the other one "Unprotect Sheet", right ? what you want is when you click on one of these that you protect / unprotect your sheet ?
Juan Pablo
Juan,
I was thinking along the lines of only the one option button that toggles either ON or OFF. Is that at all possible?
Tks, Riki
Try this :-
Sub ProtectionToggle()
If Application.ExecuteExcel4Macro("get.document(7)") = True Then
ActiveSheet.Unprotect
Else
ActiveSheet.Protect
End If
End Sub
Thanks Josef - exactly what I was after, and thanks Juan. I'm learning a lot from this forum and I appreciate those who respond.
Cheers Riki Try this :- Sub ProtectionToggle()