Using a Check Box to Lock/Unlock Cells

A

adambush4242

I created a check box and want to link a macro to it. My worksheet is going
to be protected at all times. The macro needs to unlock a certain range of
cells when the check box is checked on, and re-lock the cells when the box is
unchecked. Any Ideas?

Thanks

Adam Bush
 
T

Tom Hutchins

Private Sub CheckBox1_Click()
Dim StartCell As Range
Set StartCell = ActiveCell
Range("RngAA").Select
If CheckBox1.Value = True Then
Selection.Locked = True
Else
Selection.Locked = False
End If
StartCell.Activate
Set StartCell = Nothing
End Sub

In this example, the checkbox is named CheckBox1, the desired range is
RngAA, and the checkbox is on the same sheet as RngAA. You would need to
modify the code if the checkbox is on a different sheet than RngAA.

Hope this helps,

Hutch
 

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