VBA: change cell to blank based on change to another

Joined
Apr 18, 2012
Messages
2
Reaction score
0
Hi everyone,

Scenario 1 (currently working): I wrote the below macro in order to change D4 and D5 to blank when the D3 selection (drop down selection) is changed. Since these cell are linked, when the D3 dropdown changes the users will be forced to make a new selection from D4 and D5.

Scenario 2 (what I would like to accomplish): Now I would like to make D5 become blank when the selection for D4 changes, but I am not able to make it do that.

Here is the code that is working right now for scenario 1:

Private Sub worksheet_change(ByVal Target As Range)
If Target.Address <> "$D$3" Then Exit Sub
Range("D4").ClearContents
Range("D5").ClearContents
Range("D14").ClearContents
Range("D15").ClearContents
End Sub
 
Joined
Apr 19, 2012
Messages
6
Reaction score
0
Hi mjkd,

Try something like

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$3" Then
'Exit Sub
Range("D4").ClearContents
Range("D5").ClearContents
Range("D14").ClearContents
Range("D15").ClearContents
ElseIf Target.Address = "$D$4" Then
Range("D5").ClearContents
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top