View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Writing update date and time in a cell on inputs

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Column < 4 Then
With Target
If .Value = "" Then
.Offset(0,1).Value = ""
Else
.Offset(0, 1).Value = Date & " " & Time
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"a94andwi" wrote in
message ...

GB Wrote:

'Code starts here
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then 'This checks to see if the change was made
in
column A
Application.EnableEvents = False 'Prevents running this again with
the following change
Sheet1.Cells(Target.Row, 2).Value = Date & " " & Time 'This assigns
column B to the current Time (possibly date also)
Application.EnableEvents = True 'Reenables events
End If

End Sub

QUOTE]


Hello.

This works great. I'm interested in developing this function so that it
erases the date and time column when column 1, 2, 3 are erased/cleared.
This must be very easy but when you do not know how to code in VBA then
it isn't.

Is there a simple way to handle this?

/Anders



--
a94andwi
------------------------------------------------------------------------
a94andwi's Profile:

http://www.excelforum.com/member.php...o&userid=21077
View this thread: http://www.excelforum.com/showthread...hreadid=501065