protect unprotect toggle VBA

  • Thread starter Thread starter Wanna Learn
  • Start date Start date
W

Wanna Learn

Hello I want to create a checkbox that when the box is checked rows 1 thru
70 are protected and when the box is unchecked worksheet is unprotected. I
created a macro to protect the sheet, then I created a macro to unprotect the
sheet . I combined both macros but it does not toggle. Thanks in advance
 
Without a crystal ball, it's tough to know why your code doesn't do what you
want. Please post it and then we can assist.

Barb Reinhardt
 
Hello  I want to create a checkbox that when the box is checked rows 1 thru
70 are protected and when the box is unchecked worksheet is unprotected.  I
created a macro to protect the sheet, then I created a macro to unprotectthe
sheet . I combined both macros but it does not toggle.   Thanks in advance

What happened to the CheckBox?
 
I see you've already posted this before and have an answer. I realize the
web interface is having issues, but please verify that your question hasn't
been answered before posting again.
 
Here is a minimal sample

Private Sub CheckBox1_Click()
With CheckBox1
If .Caption = "Protect" Then
ActiveSheet.Protect
.Caption = "Unprotect"
Else
.Caption = "Protect"
ActiveSheet.Unprotect
End If
End With
End Sub

which I attached to a Control Toolbox checkbox
 
Back
Top