Hi All
I need help with code to lock cell in the same row with "Environmental" or "Safety " value.
Column H Contains either Environmental" or "Safety
If Safety is selected I need the cell on the same row in column J to lock preventing someone from entering data
If Environmental is selected I need the cell on the same row in column I to Lock
I have written some code but it doesn't work it.
Hoping someone can help and show me where I went wrong
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
ActiveSheet.Unprotect
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each cell In Target
If Range("H" & cell.Row) = "Environmental" Then
If IsEmpty(Range("J" & cell.Row)) Then Range("J" & cell.Row) = cell.Locked = True
ElseIf Range("H" & cell.Row) <> "Safety" Then
Range("I" & cell.Row) = cell.Locked = True
End If
Next cell
ActiveSheet.Protect
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Bookmarks