I have written the following code:
Dim myValue As Variant
Dim myValue2 As Variant
Dim myValue3 As Variant
Dim myValue4 As Variant
On Error GoTo ErrorOccured
If Target.Address = "$B$10" And Target.Value = "Yes" Then
myValue = InputBox("Insert initialDate1")
myValue2 = InputBox("Insert initialDate2")
Range("C10").Value = myValue
Range("D10").Value = myValue2
End If
If Target.Address = "$B$12" And Target.Value = "Yes" Then
myValue3 = InputBox("InitialDate3")
myValue4 = InputBox("InitialDate4")
Range("C12").Value = myValue3
Range("D12").Value = myValue4
End If
ErrorOccured:
'Do when value is not valid
End Sub
Its purpose is the following: if I select Yes from a drop down list, the code must ask me to fill a beginning and ending date of the first event and then it should go to the second event, again select yes from a drop down list and ask for beginning and and dates. My problem is that I don't know how to connect these two conditions so that they stay independent. I cannot use And Or, Else or the other classic connectors. I should be able to select Yes for the first Event and input the dates and for ex select No for the second event end no pop up appears. It worked when I wrote the code for only one Event
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue As Variant
Dim myValue2 As Variant
On Error GoTo ErrorOccured
If Target.Address = "$B$10" And Target.Value = "Yes" Then
myValue = InputBox("Insert initialDate1")
myValue2 = InputBox("Insert initialDate2")
Range("C10").Value = myValue
Range("D10").Value = myValue2
End If
ErrorOccured:
End Sub
Please, could you help me with this one?
Aucun commentaire:
Enregistrer un commentaire