alantse2010
New Member
- Joined
- Jun 9, 2018
- Messages
- 34
- Office Version
- 365
- 2019
- 2016
- 2010
- Platform
- Windows
Hi all, 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 anyone cell value changed.
When the value of D18 is "NA", the value of E19 to E24 is "NA".
When the value of D18 is "C", the value of E19 to E24 is "C".
When the value of E19 to E24 anyone is "NC", the value of D18 is "NC".
Then, it has cause the error "type mismatch" when D18 changed to "NA" or "C".
Anyone can guide me how to fix it?
Thank you very much.
When the value of D18 is "NA", the value of E19 to E24 is "NA".
When the value of D18 is "C", the value of E19 to E24 is "C".
When the value of E19 to E24 anyone is "NC", the value of D18 is "NC".
Then, it has cause the error "type mismatch" when D18 changed to "NA" or "C".
Anyone can guide me how to fix it?
Thank you very much.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'If ActiveSheet.Range("D18").Value = "C" Then
'ActiveSheet.Range("E19:E24").Interior.ColorIndex = 8
'
'Else
'ActiveSheet.Range("E19:E24").Interior.ColorIndex = 2
'
'End If
If Not Intersect(Target, Range("D18")) Is Nothing Then
Select Case Target.Value
Case "NA"
Range("E19:E24").Value = "NA"
Case "C"
Range("E19:E24").Value = "C"
End Select
End If
If Not Intersect(Target, Range("E19:E24")) Is Nothing Then
Select Case Target.Value
Case "NC"
Range("D18").Value = "NC"
End Select
End If
End Sub