1) Put this macro into the ThisWorkbook module, edit it to refer to the correct sheet and the correct password.
Private Sub workbook_Open()
Sheets("Sheet1").Protect "password", UserInteraceOnly:=True
End Sub
Even though the sheet is protected, setting the UserInterfaceOnly flag when the workbook opens allows VBA to make changes to the sheet without protecting/unprotecting over and over.
2) Place this macro into the Sheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
On Error Resume Next
For Each cell In Target
If Not Intersect(cell, Range("C17:C167")) Is Nothing Then
If IsNumeric(cell) And cell <> 0 Then _
Range("E" & cell.Row).Resize(1, 31).Locked = False
End If
Next cell
End Sub
As you work on the sheet, if you place a number into any cell in range C17:C167, that row will be unlocked. Happens in realtime.
Bookmarks