Delete Macro

S

Saruman

Can anyone help with a macro to delete the contents of a single cell that
contains a date, when a second cell is changed with a new date. Have tried
using the Worksheet_Change event without any success.

My file has a manually entered date in cell E3 which triggers Conditional
Formatting. When an updated date for an annual report is entered in cell G3,
I need the date in cell E3 to be deleted. This also needs to function for
all the cells in column G downwards.

Thanks In Advance

Saruman
 
G

Gord Dibben

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in any cell in Col G
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 7 Then
n = Target.Row
If Excel.Range("G" & n).Value <> "" Then
Excel.Range("E" & n).ClearContents
'or Excel.Range("E3").ClearContents
End If
End If
enditall:
Application.EnableEvents = True
End Sub

This is sheet event code.

Right-click on the sheet tab and "View Code"

Copy/paste into that module.


Gord Dibben MS Excel MVP
 
Top