You could have found very similar code if you had searched the Forum!Try this
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column > 1 Or Target.Count > 1 Then Exit Sub
ActiveSheet.Unprotect
If Target.Value = "Yes" Then
Range(Cells(Target.Row, 2), Cells(Target.Row, 5)).Cells.Locked = True
Else: Range(Cells(Target.Row, 2), Cells(Target.Row, 5)).Cells.Locked = True
End If
ActiveSheet.Protect
End Sub
To add it to your worksheet, do the following:
Copy the code that you want to use
Select the worksheet in which you want the code to run
Right click on the sheet tab and choose View Code, to open the Visual Basic Editor.
Where the cursor is flashing, choose Edit | Paste
Bookmarks