View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
JE McGimpsey
 
Posts: n/a
Default Username & Date/Time Stamp

See

http://www.mcgimpsey.com/excel/timestamp.html

One could modify one of the macros found there something like:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A1:J50"), .Cells) Is Nothing Then
Application.EnableEvents = False
Cells(.Row, 11).Value = Application.UserName
With Cells(.Row, 12)
.NumberFormat = "dd-mmm-yyyy hh:mm:ss am/pm"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub

Note that using Format(User()) does nothing except make an extra
function call, and that

Range("L1").Formula = Format(Now(), "dd-mmm-yyyy hh:mm:ss am/pm")

WIll not affect how the date/time is displayed - only the cell's
..NumberFormat property determines that. Using Format just makes the
date/time a string function which is then interpreted by XL's parser and
displayed according to the cell's number format.


In article .com,
"Ken D" wrote:

I've created the following code to record Username and a Date/Time
Stamp in cells K1 & L1 (respectively) after a user makes any change to
a cell in the same row (A1 through J1).

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A1:J1"), Target) Is Nothing Then Exit Sub
Range("K1").Formula = Format(User())
Range("L1").Formula = Format(Now(), "dd-mmm-yyyy hh:mm:ss am/pm")
End Sub

I need to repeat this code for approx 50 rows. Any advice on the most
efficient way to handle this is greatly appreciated.

Thanks,
Ken