Hi, I'm trying to lock a range when I tick a checkbox.
Ex. If I tick the checkbox in C1 the range A1:B1 get locked
The sheet is already protected but I have editable ranges
But every time I tick the checkbox all the editable ranges get locked
Ex. If I tick the checkbox in C1 the range A1:B1 get locked
The sheet is already protected but I have editable ranges
But every time I tick the checkbox all the editable ranges get locked
VBA Code:
Private Sub CheckBox1_Click()
Dim chk As OLEObject
Set chk = Me.OLEObjects(CheckBox1.Name)
Call Lock(chk)
End Sub
VBA Code:
Sub Lock(chk As OLEObject)
Dim r As Long
r = chk.TopLeftCell.Row
ActiveSheet.Unprotect Password:="Secret"
Range("A" & r).Locked = True
ActiveSheet.Protect Password:="Secret"
End Sub