0

i am using this code in excel vba and it is working fine for this row however i am wanting to apply the code to work in the same way but for all the rows in the m column based on the specific rows value and not clear contents of all the rows in the other columns based on 1 cell in the m columns value, hope this makes sense

Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("M4")) Is Nothing Then
        Range("N4:T4").ClearContents        
    End If

End Sub
BigBen
  • 46,229
  • 7
  • 24
  • 40

1 Answers1

0

Like this, using Offset and Resize on the Intersection of Target and column M.

Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Me.Range("M:M")) Is Nothing Then
        Intersect(Target, Me.Range("M:M")).Offset(, 1).Resize(, 7).ClearContents
    End If

End Sub
BigBen
  • 46,229
  • 7
  • 24
  • 40