Check Box that Locks all cells on it's column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

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

Back
Top