Check Box that Locks all cells on it's column

J

JasonMiller

Does anyone know how I could create a checkbox that when checked, would lock
all cells on that column permanently. Probably some simple macro that keeps
eluding me.
 
D

Dave Peterson

Put a checkbox from the Forms toolbar in row 1 of each of the columns you want.

Then assign this same macro to each of those checkboxes.

Option Explicit
Sub testme()

Dim myCBX As CheckBox

Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)
If myCBX.Value = xlOn Then
ActiveSheet.Unprotect Password:="hi"
myCBX.TopLeftCell.EntireColumn.Locked = True
ActiveSheet.Protect Password:="hi"
End If

End Sub

Be aware that worksheet protection is very weak. It can be broke very simply.
 
Top