I am writing the VBA that about change the cell (E19:E24) value if cell D18 value changed and change the cell D18 value if E19: E24 all or anyone cell value changed.
I want to fulfil below scenario:
- When the value of D18 is "NA", the value of E19 to E24 is "NA".
- When the value of E19 to E24 is "NC", the value of D18 is "NC".
- When the value of E19 to E24 have "C" and "NA", the value of D18 is "C".
- When the value of E19 to E24 have "C" and "NC", the value of D18 is "NC".
- When the value of E19 to E24 have "C" and "NA" and "NC", the value of D18 is "NC".
- When all the value of E19 to E24 is "C" or "NA", the value of D18 will be "C" or "NA".
Now that I have done the scenario 1 and 2, but i don't know how to write VBA for scenario 3-6.
Would anyone help me? Thank you very much.
Below is my code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(Target, Range("D18")) Is Nothing Then
If Not Intersect(Target, Range("E19:E24")) Is Nothing Then
If Target.Value = "NC" Then Range("D18").Value = "NC"
End If
Else
'Target.Value = D18 Value
Select Case Target.Value
Case "NA"
Range("E19:E24").Value = "NA"
End Select
End If
Application.EnableEvents = True