Sunscreen
Sunscreen

Reputation: 3564

Clearing out specific cells when another cell is changed

I found the following code clearing out specific cells when another cell is changed.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        Range("B1:C1").ClearContents
    End If
End Sub

I was wondering if there is a more dynamic approach to this. That is, when any of the cells A* (one each time) is changed, the adjacent B* and C* are cleared out.

Thank you,

Upvotes: 0

Views: 41

Answers (1)

BigBen
BigBen

Reputation: 50162

Check if Target intersects column A:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Me.Range("A:A")) Is Nothing Then
         Intersect(Target.EntireRow, Me.Range("B:C")).ClearContents
    End If
End Sub

Upvotes: 1

Related Questions