You can achieve what you want in two ways. 1. If you want to lock column L automatically when you choose "Not Progressing" in the drop down list in column E, you have to copy and paste the following macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make your selection in column E and the macro will run automatically.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E:E")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
ActiveSheet.Unprotect
If Target = "Not Progressing" Then
Cells(Target.Row, "L").Locked = True
Else
Cells(Target.Row, "L").Locked = False
End If
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub
2. If you want to run the macro manually, use the following macro in a regular module:
Sub LockCells()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Dim bottomE As Long
bottomE = Range("E" & Rows.Count).End(xlUp).Row
Dim rng As Range
For Each rng In Range("E5:E" & bottomE)
If rng = "Not Progressing" Then
Cells(rng.Row, "L").Locked = True
Else
Cells(rng.Row, "L").Locked = False
End If
Next rng
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub
Use one or the other, not both.
Bookmarks