I need help in locking specific range of cells based on the selection of value from list from another cell.
To be specific, I have created data validation list for columns N5 to N36, upon selection of value "Exist" from the cell N5, I want to lock that specific row O5 to U5.
i.e "Exist" in N6 would lock O6 to U6 and so on.
Similarly for the other rows till N36.
And if the user selects "Does not Exist", then I would want those cells to remain unlocked and editable similar to the above condition.
I have tried macros from various forums using my very basic knowledge of using macros, but most of those lock the entire sheet.
Code I tried:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("N5:N36")) Is Nothing Then
ActiveSheet.Unprotect
If Target.Value = "Exist" Then
Range("O" & Target.Column & ":U" & Target.Column).Select Selection.Locked = False
Else
Range("O" & Target.Column & ":U" & Target.Column).Select Selection.Locked = True
End If
End If
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
I would really appreciate your quick help.
Thanks in Advance.