Date-time stamp

D

Daniel

Hello,

My name is Daniel,
Can you please help me with some code to do the following in Excel:

Have one spreadsheet (with some protection I think); whenever someone
alters the content of some cells, a DateTime stamp should be stored in another
cell (protected).

Thank you
 
J

Jacob Skaria

For any changes done to unprotected area Range("A1:A20") a date/time stamp is
set in Column C which is the protected area. Right click the sheet tab>View
Code> and paste the below code to the code module..

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A20")) Is Nothing Then
If Target.Count = 1 Then
Me.Unprotect Password:="dist"
Range("C" & Target.Row) = Format(Now, "mmm dd, yyyy h:mm AMPM;@")
Me.Protect Password:="dist"
End If
End If
Application.EnableEvents = True
End Sub


If this post helps click Yes
 
M

Mike H

Daniel,

This assumes the cells where you enter the data are not protected and in
this case it's A1 - A100. Right click your sheet tab, view code and paste the
code below in. Enter data entered in a1 - A100 and you get the timestamp in
the corresponding B1 - B100

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="MyPass"
Target.Offset(, 1) = Now
ActiveSheet.Protect Password:="MyPass"
Application.EnableEvents = True
On Error GoTo 0
End If
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Date stamp user 7
Date Stamp 7
time stamp question 2
Auto Stamp Date 13
Time Stamp 8
Remove Time from DateTime 4
Excel Excel 2010 Time Stamp Button Help 1
Selecting Last Record 5

Top