protect worksheet with check box

W

Wanna Learn

Hello
I added a check box using the control tool box. Then in the sheet code I
added the following
Private Sub CheckBox1_Click()
Rows("1:68").Select
ActiveSheet.Protect "pass"
ActiveSheet.Unprotect "pass"
End Sub
THis is what Im trying to do when the check box is selected or checked
then rows 1 thru 68 will be protected else if the checked box is uncheck
sheet is unprotected

thanks in advance
 
C

CurlyDave

Try this

Private Sub CheckBox1_Click()

With Worksheets("Sheet1")
ActiveSheet.Unprotect "pass"
Cells.Locked = False
End With

If CheckBox1 = True Then
Rows("1:68").Locked = True
ActiveSheet.Protect "pass"
Else: Rows("1:68").Locked = True
End If

End Sub
 

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