I have this file with the code to lock the cell after input with the code below
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("b9:h9, b12:h12, b19:h19, b21:h21, b31:h31")) Is Nothing Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="cream"
Target.Locked = True
ActiveSheet.Protect Password:="cream"
Application.EnableEvents = True
End Sub
However I tried to implement this code below to clear the cell range at the end of the week with the clear button in sheet called setup
Sub dotch()
Application.EnableEvents = False
With Sheets("£SAFE LOG")
.Unprotect Password:="cream"
With .Range("B9:H9, B12:H12, B19:H19, B21:h21, B31:H31")
.ClearContents
.Locked = False
End With
End With
Application.EnableEvents = True
End Sub
This code does work to clear the cells but the cells will not lock anymore
I tried reverting the clear code to what it was before..(the original code was throwing up errors hence the change)
even stranger the original code now clears the cell range as well but i think that is because the locking code in Safe Log is no longer working
Sub Rectangle3_Click()
With Sheets("£SAFE LOG")
.Unprotect Password:="cream"
With .Range("B9:H9, B12:H12, B19:H19, B21:h21, B31:H31")
.ClearContents
.Locked = False
End With
End With
End Sub
How do I make the cell locking code work again?
Thank you
Bookmarks