
Originally Posted by
abousetta
Maybe try:
Cells(Target.Row,"A").ClearContents
Range(Cells(Target.Row, "C"), Cells(Target.Row, "XFD")).ClearContents
The above did something funky ... so I just did this messy but it works:
Private Sub Worksheet_Change(ByVal Target As Range)
' If target is not within D3:D350 then quit
If Intersect(Target, Range("D3:D350")) Is Nothing Then Exit Sub
' Disable event handling while THIS macro is changing the sheet
Application.EnableEvents = False
' if the target cell has just been cleared then clear the entire row
' otherwise put the date in column "H"
Select Case Target.Value
Case Is = Empty
Cells(Target.Row, "A").ClearContents
Cells(Target.Row, "C").ClearContents
Cells(Target.Row, "E").ClearContents
Cells(Target.Row, "F").ClearContents
Cells(Target.Row, "G").ClearContents
Cells(Target.Row, "H").ClearContents
Case Is <> Empty
Target.Offset(0, 4).Value = Date
Select Case Month(Target.Offset(0, 4))
Case 11, 12, 1
Cells(Target.Row, 1).Value = "Q1"
Case 2, 3, 4
Cells(Target.Row, 1).Value = "Q2"
Case 5, 6, 7
Cells(Target.Row, 1).Value = "Q3"
Case 8, 9, 10
Cells(Target.Row, 1).Value = "Q4"
End Select
End Select
' re-enable event handling and quit
Application.EnableEvents = True
End Sub
*** Part of the code above clears the data in cells when the data is deleted from D
*** Can a pop up be added to asK
"Are you sure you want to clear the data in this row"
With an option:
Yes - exceute code above
No - Does not exectute code to clear
Bookmarks