Hi I am using the following VBA to lock a cell:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("D22")) Is Nothing) And Target.Cells.Count = 1 Then
ActiveSheet.Unprotect
If Target.Value = "Y" Then
Target.Offset(0, 3).Locked = False
Else
Target.Offset(0, 3).Locked = True
End If
ActiveSheet.Protect
End If
If Not (Intersect(Target, Range("A24")) Is Nothing) And Target.Cells.Count = 0 Then
ActiveSheet.Unprotect
If Target.Value = "Y" Then
Target.Offset(0, 3).Locked = False
Else
Target.Offset(0, 3).Locked = True
End If
ActiveSheet.Protect
End If
End Sub
The first part works fine but the second does not work..I have a formula in
A24 as getting "Y" in that cell is based on different scenarios..
I was wondering if there is anything I can do so the VBA does not recognise a formula as an entry into the cell as I presume this is what is causing the problem..
Thanks
Mark
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("D22")) Is Nothing) And Target.Cells.Count = 1 Then
ActiveSheet.Unprotect
If Target.Value = "Y" Then
Target.Offset(0, 3).Locked = False
Else
Target.Offset(0, 3).Locked = True
End If
ActiveSheet.Protect
End If
If Not (Intersect(Target, Range("A24")) Is Nothing) And Target.Cells.Count = 0 Then
ActiveSheet.Unprotect
If Target.Value = "Y" Then
Target.Offset(0, 3).Locked = False
Else
Target.Offset(0, 3).Locked = True
End If
ActiveSheet.Protect
End If
End Sub
The first part works fine but the second does not work..I have a formula in
A24 as getting "Y" in that cell is based on different scenarios..
I was wondering if there is anything I can do so the VBA does not recognise a formula as an entry into the cell as I presume this is what is causing the problem..
Thanks
Mark