Thread: date/time stamp
View Single Post
  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

First, note that the macro as written will give undesired results if a
multiple selection includes more than one column, including column A.
For instance, if A1:J10 is selected with C5 active, and C5 is changed by
the user, all the cells in B1:K10 will be overwritten with the date
stamp. One way to handle that would be to abort if there's a multiple
selection.

Second, Time only returns the time. For dates as well, use Now instead.

I might amend the macro like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rSelect As Range
With Target
If .Count 1 Then Exit Sub
If Not Intersect(.Cells, Me.Range("A:A")) Is Nothing Then
Application.EnableEvents = False
With .Offset(0, 1)
.Value = Now
.NumberFormat = "dd/mm/yy hh:mm AM/PM"
End With
End If
End With
ws_exit:
Application.EnableEvents = True
End Sub



In article ,
Jan wrote:

I tried to adapt the number format so that date and time display because I
need to have both. I have replaced your " "hh:mm:ss" with ""mm/dd/yy h:mm
AM/PM;@".
However, no matter what format I try to use the date displays as 01/0/1900.
Do you have any suggestions to the the date display as the current date?