Eurekaonide
Active Member
- Joined
- Feb 1, 2010
- Messages
- 433
Hi All
I think there is probably something very small and simple I am missing here as it did seem to work but now is not.
I have a form with checkboxes on it, when a checkbox is selected it will Lock the cells for editing in the corresponding Column, hide the column off and then when the OK button is pressed it protects the sheet (currently without a password).
For some reason it is now not locking the cells.
and this is the code for the OK button
Can you see what I am doing wrong please?
I think there is probably something very small and simple I am missing here as it did seem to work but now is not.
I have a form with checkboxes on it, when a checkbox is selected it will Lock the cells for editing in the corresponding Column, hide the column off and then when the OK button is pressed it protects the sheet (currently without a password).
For some reason it is now not locking the cells.
VBA Code:
This is an example of the code for the checkboxes
Private Sub CheckBox1_Click()
Sheets("Data").Select
ActiveSheet.Unprotect
If Me.CheckBox1.Value = True Then
Sheets("Data").Columns("Q:Q").Hidden = True
Selection.Locked = True
ElseIf Me.CheckBox1.Value = False Then
Sheets("Data").Columns("Q:Q").Hidden = False
Selection.Locked = False
End If
End Sub
and this is the code for the OK button
VBA Code:
Private Sub CommandButton1_Click() 'OK
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True, _
AllowInsertingRows:=True, AllowFiltering:=True, AllowFormattingColumns:=True
Unload Me
End Sub
Can you see what I am doing wrong please?
Last edited by a moderator: