Thread: Time Stamp
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
FARAZ QURESHI FARAZ QURESHI is offline
external usenet poster
 
Posts: 553
Default Time Stamp

Thanx 4 your help Gord, but the code doesn't seem to b working when I paste
an array or range suppose upon cells A1:A10 to reflect timestamp upon B1:B10

"Gord Dibben" wrote:

Faraz

When you enter data in Column A either by direct entry or pasting, Column B will
get a time stamp if none is currently there. If B has a time stamp it will not
change.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall

Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < ""
And Excel.Range("B" & n).Value = "" Then
Excel.Range("B" & n).Value = Now
End If
End If
enditall:
Application.EnableEvents = True
End Sub

An alternative to actually lock column B before and after the time stamp is
entered.

Unlock all columns except for Column B then protect the sheet with the password
"justme"(no quotes)

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
ActiveSheet.Unprotect Password:="justme"
n = Target.Row
If Target.Value < "" _
And Target.Offset(0, 1).Value = "" Then
With Target.Offset(0, 1)
.Value = Now
.Locked = True
End With
End If
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme"
End Sub


Gord Dibben MS Excel MVP


On Sat, 6 Jan 2007 12:56:00 -0800, FARAZ QURESHI
wrote:

Any macro to add time of recording in cells of column A into corressponding
cells of column B, whether the entry is punched in or multiple ones are
pasted? Having the time recorded so to be values so as to restrict from being
changed.