Hi below is my subroutine. What it does is to unlock a range in a column based on a cell being "empty" or "filled" with data.
So for example If F3 is empty F10 to F54 is locked, Else IF F3 has data that range is unlocked.
The problem is that the subroutine is unstable. Sometimes I get runtime error 13 and the debugger highlights the line
If Target.Value = "" Then
Here's the subroutine....
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F3:O3")) Is Nothing Then
If Target.Value = "" Then
Sheets(ThisWorkbook.ActiveSheet.Name).Unprotect Password:="1234" 'change to your actual password
Range(Cells(10, Target.Column), Cells(54, Target.Column)).ClearContents
Range(Cells(10, Target.Column), Cells(54, Target.Column)).Locked = True
Sheets(ThisWorkbook.ActiveSheet.Name).Protect Password:="1234"
Else
Sheets(ThisWorkbook.ActiveSheet.Name).Unprotect Password:="1234" 'change to your actual password
Range(Cells(10, Target.Column), Cells(54, Target.Column)).Locked = False
Sheets(ThisWorkbook.ActiveSheet.Name).Protect Password:="1234"
End If
End If
End Sub
Bookmarks