DateTime & Username stamp

Spraggs

Well-known Member
Joined
Jan 19, 2007
Messages
704
Hello All,
I'm working in a spreadsheet Sheet1.
When any data is entered in F2:F2000 and saved, I would like to enter date/time & username stamp in the corresponding cells in column X Y & Z.
i.e. data entered in F27
X27 = 19/05/2010
Y27 = 15:21
Z27 = Joe Bloggs

Is this possible using Vba ?
If it is what is the code and how do I use it.

Any help is much appreciated.
 
Confused by your code!!
What do you want to happen when a cell in Column "F" is changed?
What is to happen when Column "P" is changed?
Where do you want the comments?
What columns do you want the Date,Time and UserNmae in?

lenze
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello,
I've used VoG's code to enter the username, date & code in columns x,y & z when column F (same row) is changed, this works fine. Then after seeing your comment thought I'd try and add the comment box code to column X2:X2000. Don't know if this is possible and if it is, what would the full code would be.
Thanks for your valued time.
 
Upvote 0
Give this a try!!
Code:
Option Explicit
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F2:F2000")) Is Nothing Then
   Application.EnableEvents = False
   With Target
     .Offset(, 18).Value = Date
     .Offset(, 19).Value = Time
     .Offset(, 20).Value = Environ("username")
   End With
   Application.EnableEvents = True
ElseIf Not Intersect(Target, Range("P2:P2000")) Is Nothing Then
   Target.ClearComments
   Target.AddComment.Text Text:="Previous Value was " & preValue & Chr(10) & "Revised " & Format(Date, "mm-dd-yyyy") & Chr(10) & "By " & Environ("UserName")
Else: Exit Sub
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("P2:P2000")) Is Nothing Then Exit Sub
If Target = "" Then
preValue = "a blank"
Else: preValue = Target.Value
End If
End Sub

lenze
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top