Richard44444
New Member
- Joined
- Aug 10, 2018
- Messages
- 1
Hi
I know this has been covered a few times and people have posted replies, from which I copied and amended some code which first worked and now does not for some reason. Can anyone help?
I have 4 column dependency lists with info in G4, H4, I4 and I4, If any changes are made to G4 I want all other columns to clear data, for H4 I want I4 and J4 to clear any content and if I4 is changed I want J4 data to clear.
I have used the following which worked for about a week but has now stopped working.
Private Sub Worksheet_Change(ByVal Target As Range)
'When G4 changes, H4 clears, and I4, J4 all clear.
If Target.Address(0, 0) = "G4" Then
Range("H4:I4, J4").ClearContents
'When H4 changes, I4, J4 all clear.
ElseIf Target.Address(0, 0) = "H4" And Range("A1").Value <> "N" Then
Range("I4:J4").ClearContents
'When I4 changes, J4, all clear.
ElseIf Target.Address(0, 0) = "I4" And Range("A1").Value <> "N" Then
Range("J4").ClearContents
End If
End Sub
Help appreciated by a coding beginner
Richard
I know this has been covered a few times and people have posted replies, from which I copied and amended some code which first worked and now does not for some reason. Can anyone help?
I have 4 column dependency lists with info in G4, H4, I4 and I4, If any changes are made to G4 I want all other columns to clear data, for H4 I want I4 and J4 to clear any content and if I4 is changed I want J4 data to clear.
I have used the following which worked for about a week but has now stopped working.
Private Sub Worksheet_Change(ByVal Target As Range)
'When G4 changes, H4 clears, and I4, J4 all clear.
If Target.Address(0, 0) = "G4" Then
Range("H4:I4, J4").ClearContents
'When H4 changes, I4, J4 all clear.
ElseIf Target.Address(0, 0) = "H4" And Range("A1").Value <> "N" Then
Range("I4:J4").ClearContents
'When I4 changes, J4, all clear.
ElseIf Target.Address(0, 0) = "I4" And Range("A1").Value <> "N" Then
Range("J4").ClearContents
End If
End Sub
Help appreciated by a coding beginner
Richard