I am trying to set up an excel workbook that will run something like a time clock. I want certain cells to be locked to all without a password and certain cells to lock once a person has entered data into them. These will all be on the same sheet. I've gotten each to work without the other turned on but as soon as I try to make it all work at the same time it freaks out (i.e. the cells that are supposed to lock after data entry start locking everytime the worksheet is protected, or ask for a password to enter data, etc) It seems like the info I'm using is misreading somewhere. I'm very new to using VBA so I'm having trouble trouble-shooting it. Here's a copy of the VBA I'm using to lock the cells after data entry. If you need more information please let me know. Any help anyone can give would be awesome! Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("H4:H30")) Is Nothing Then
If Target.Locked = False Then
ActiveSheet.Unprotect "1234"
Target.Locked = True
ActiveSheet.Protect "1234"
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("H4:H30")) Is Nothing Then
If Target.Locked = False Then
ActiveSheet.Unprotect "1234"
Target.Locked = True
ActiveSheet.Protect "1234"
End If
End If
End Sub