Hi,
I am working on the following code:
In B13 user can choose from a validation list "Yes" or "No". If they choose "No" then B14 & B15 should lock (meaning they shouldn't be able to enter a value) and if there was a value other than 0, it should reset to 0. Sometimes users may first answer "Yes" enter values in B14 and B15 then decide to change B13 to "No". If they do so, I need to lock and reset B14 and B15. However, this code isn't doing what I need. Please note that I also have other Workshee_Change events for the same sheet. If I try to use it on a new book, sometimes it work, sometimes it doesn't. On the original file, it never works. The macros are enabled from the options. Any idea on what is wrong? Thank you.
I am working on the following code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "B13" Then
Dim cellValue1 As String
cellValue1 = Target.Value
If cellValue1 = "No" Then
Range("B14:B15").Locked = True
Range("B14:B15").Value = 0
MsgBox "If you have selected ""No"" in the previous question, you can't enter a value here."
Else
Range("B14:B15").Locked = False
End If
End If
End Sub
In B13 user can choose from a validation list "Yes" or "No". If they choose "No" then B14 & B15 should lock (meaning they shouldn't be able to enter a value) and if there was a value other than 0, it should reset to 0. Sometimes users may first answer "Yes" enter values in B14 and B15 then decide to change B13 to "No". If they do so, I need to lock and reset B14 and B15. However, this code isn't doing what I need. Please note that I also have other Workshee_Change events for the same sheet. If I try to use it on a new book, sometimes it work, sometimes it doesn't. On the original file, it never works. The macros are enabled from the options. Any idea on what is wrong? Thank you.
Last edited by a moderator: