I am trying to write some code in Private Sub Worksheet_Change sheet module that will unlock and lock cells depending if they are blank or not.
I have got this far:
'to unlock H
If Not Intersect(Target, Range("B11:B81")) Is Nothing Then
ActiveSheet.UnProtect Password:="PASSWORD"
Cells(Target.Row, "H").Locked = False
ActiveSheet.Protect Password:="PASSWORD"
End If
'to lock H
If Intersect(Target, Range("B11:B81")) Is Nothing Then
ActiveSheet.UnProtect Password:="PASSWORD"
Cells(Target.Row, "H").Locked = True
ActiveSheet.Protect Password:="PASSWORD"
End If
So basically, if something is entered in the cell range B11 to B81, then unlock the cells H, if there is nothing in the call range B11 to B81 then lock the cells H.
What this seems to do is unlock and lock H at the same time and doesnt matter if the cell range is empty or not.
Has anyone got any ideas on how to resolve this please?
Many thanks for any suggestions supplied to my post.
I have got this far:
'to unlock H
If Not Intersect(Target, Range("B11:B81")) Is Nothing Then
ActiveSheet.UnProtect Password:="PASSWORD"
Cells(Target.Row, "H").Locked = False
ActiveSheet.Protect Password:="PASSWORD"
End If
'to lock H
If Intersect(Target, Range("B11:B81")) Is Nothing Then
ActiveSheet.UnProtect Password:="PASSWORD"
Cells(Target.Row, "H").Locked = True
ActiveSheet.Protect Password:="PASSWORD"
End If
So basically, if something is entered in the cell range B11 to B81, then unlock the cells H, if there is nothing in the call range B11 to B81 then lock the cells H.
What this seems to do is unlock and lock H at the same time and doesnt matter if the cell range is empty or not.
Has anyone got any ideas on how to resolve this please?
Many thanks for any suggestions supplied to my post.