protect unprotect toggle VBA

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
 
B

Barb Reinhardt

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
 
C

CurlyDave

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?
 
B

Barb Reinhardt

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.
 
S

Shane Devenshire

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top