• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to clear cell contents in corresponding cells

srinidhi

Active Member
Column D has a drop down list.

When I select a new text in column D the contents in the corresponding cells e & F should get cleared.I am using the following code.


Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("d3:d150")) Is Nothing Then Exit Sub

[e3:f150].ClearContents

End Sub


The problem is if I select a text from d5 the text in e3 , F3, e4 & F4 is getting cleared.

I want the values to get cleared only in that particular row.

Ex: If I select a text from D5, the text from e5 & F5 should be cleared & not from e3 , F3, e4 & F4.
 
Give this a go

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("d3:d150")) Is Nothing Then
Exit Sub
Else
Cells(Target.Row, 5).ClearContents
Cells(Target.Row, 6).ClearContents
End If
End Sub
[/pre]
 
Back
Top