#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 48
Default Delete Macro

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


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Delete Macro

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

On Wed, 12 Jul 2006 21:32:58 +0100, "Saruman" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 48
Default Delete Macro

Thank you for a very quick reply.

Works awesome.

Regards
Saruman

"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
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

On Wed, 12 Jul 2006 21:32:58 +0100, "Saruman" wrote:

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




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Delete Macro

Thanks for the feedback.

Gord

On Wed, 12 Jul 2006 22:22:12 +0100, "Saruman" wrote:

Thank you for a very quick reply.

Works awesome.

Regards
Saruman

"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
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

On Wed, 12 Jul 2006 21:32:58 +0100, "Saruman" wrote:

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




Gord Dibben MS Excel MVP
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete picture with macro Steve Excel Discussion (Misc queries) 1 March 16th 06 10:12 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Error when trying to delete a macro... Currie Excel Discussion (Misc queries) 5 July 6th 05 07:31 PM
Can't find macro in an Excel file to delete it Ron Excel Discussion (Misc queries) 3 July 1st 05 01:07 PM
Macro data selection line delete Frantic Excel-er Excel Discussion (Misc queries) 0 May 31st 05 11:46 PM


All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"