Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
this code will insert the date in column BD when certain criteria is met in column Y. Should the cell in Y change from "W" or become blank at a later date, how do I adapt this code to remove the date that it has put in? Private Sub Worksheet_Change(ByVal Target As Range) ' Enters date automatically in BD when "Withdraw or Continue" (Y) = "W" Application.EnableEvents = False If Not Intersect(Target, Me.Range("Y4:Y4000")) Is Nothing Then With Target If .Value = "W" Then .Offset(0, 31).Value = Format(Date, "dd mmm yy") End If End With End If Application.EnableEvents = True End Sub Thanks! -- Traa Dy Liooar Jock |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_Change(ByVal Target As Range)
' Enters date automatically in BD when "Withdraw or Continue" (Y) = "W" Application.EnableEvents = False If Not Intersect(Target, Me.Range("Y4:Y4000")) Is Nothing Then With Target If .Value = "W" Then .Offset(0, 31).Value = Format(Date, "dd mmm yy") ELSE .Offset(0, 31).Value ="" End If End With End If Application.EnableEvents = True End Sub "Jock" wrote: Hi all, this code will insert the date in column BD when certain criteria is met in column Y. Should the cell in Y change from "W" or become blank at a later date, how do I adapt this code to remove the date that it has put in? Private Sub Worksheet_Change(ByVal Target As Range) ' Enters date automatically in BD when "Withdraw or Continue" (Y) = "W" Application.EnableEvents = False If Not Intersect(Target, Me.Range("Y4:Y4000")) Is Nothing Then With Target If .Value = "W" Then .Offset(0, 31).Value = Format(Date, "dd mmm yy") End If End With End If Application.EnableEvents = True End Sub Thanks! -- Traa Dy Liooar Jock |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 14 Sep 2009 08:43:02 -0700, Patrick Molloy
wrote: Private Sub Worksheet_Change(ByVal Target As Range) ' Enters date automatically in BD when "Withdraw or Continue" (Y) = "W" Application.EnableEvents = False If Not Intersect(Target, Me.Range("Y4:Y4000")) Is Nothing Then With Target If .Value = "W" Then .Offset(0, 31).Value = Format(Date, "dd mmm yy") ELSE .Offset(0, 31).Value ="" End If End With End If Application.EnableEvents = True End Sub Just a thought. The OP might want to "clear" the target cell rather than set it to "" e.g: ELSE .Offset(0,31).Clear (or ClearContents) --ron |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
then change
..Offset(0, 31).Value ="" to ..Offset(0, 31).ClearContents "Ron Rosenfeld" wrote: On Mon, 14 Sep 2009 08:43:02 -0700, Patrick Molloy wrote: Private Sub Worksheet_Change(ByVal Target As Range) ' Enters date automatically in BD when "Withdraw or Continue" (Y) = "W" Application.EnableEvents = False If Not Intersect(Target, Me.Range("Y4:Y4000")) Is Nothing Then With Target If .Value = "W" Then .Offset(0, 31).Value = Format(Date, "dd mmm yy") ELSE .Offset(0, 31).Value ="" End If End With End If Application.EnableEvents = True End Sub Just a thought. The OP might want to "clear" the target cell rather than set it to "" e.g: ELSE .Offset(0,31).Clear (or ClearContents) --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do i remove the auto date function from a cell to allow # rang | Excel Discussion (Misc queries) | |||
Renaming a tab to a date from a cell value (Tom Ogilvy code) | Excel Programming | |||
Remove Cell Color after Code is Deleted | Excel Discussion (Misc queries) | |||
How to remove hyperlink from a cell using VBA code | Excel Programming | |||
Way to have VB code to filter on entries that have cell with today's date? | Excel Programming |