auto time entry

  • Thread starter Thread starter papa
  • Start date Start date
P

papa

I am trying to create (as much as my inexperience will
allow) a routine that will update the date/time in cell
h23 everytime the content in g23 changes. Below I have an
attempt that doesn't seem to do anything.

Any help would be very appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("g23")) Is Nothing
Then Exit Sub
Application.EnableEvents = False
With Me.Cells(Target.Row, "h23")
.Value = Date
.NumberFormat = "mm/dd/yyy"
End If

End Sub
 
I checked the website and copied and pasted into my
worksheet to see how it would work.
Here is what I have now:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A2:A7"), .Cells) Is
Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, 1)
.NumberFormat = "dd mmm yyyy
hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub

The only thing I changed was the range from A2:A10 to
A2:A7.
Iguess I can't figure out where the stamp is located, or
if it is even displayed. I see no evidence of anything
happening. Maybe that is the way it is supposed to be,
but I need something visible for the stamp to be effective.

Thanks.
 
Did you put it in the worksheet's code module (right-click on the
worksheet tab and choose View Code)?

Otherwise your code should work fine, putting a date/time in the cell in
B2:B7 corresponding to the cell you entered the data in.
 

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

Back
Top