Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
jrm jrm is offline
external usenet poster
 
Posts: 15
Default need help with timestamp macro

I'm currently using this macro to create a timestamp in excel:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("J:K"), .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

problem is the date keeps on popping up to the right of the edited cell.
I would like to be able to monitor two columns ie, J:K, and the timestamp to
show up in the same row but in column L. Is there a way to do it? I'm
really preetty new at VBA and any help would be much appreciated. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default need help with timestamp macro

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
Set r = Cells(Target.Row, "L")
If .Count 1 Then Exit Sub
If Not Intersect(Range("J:K"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
r.ClearContents
Else
With r
.NumberFormat = "dd mmm yyyy hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub


--
Gary''s Student - gsnu200801


"jrm" wrote:

I'm currently using this macro to create a timestamp in excel:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("J:K"), .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

problem is the date keeps on popping up to the right of the edited cell.
I would like to be able to monitor two columns ie, J:K, and the timestamp to
show up in the same row but in column L. Is there a way to do it? I'm
really preetty new at VBA and any help would be much appreciated. Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.misc
jrm jrm is offline
external usenet poster
 
Posts: 15
Default need help with timestamp macro

This is great! thanks!

"Gary''s Student" wrote:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
Set r = Cells(Target.Row, "L")
If .Count 1 Then Exit Sub
If Not Intersect(Range("J:K"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
r.ClearContents
Else
With r
.NumberFormat = "dd mmm yyyy hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub


--
Gary''s Student - gsnu200801


"jrm" wrote:

I'm currently using this macro to create a timestamp in excel:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("J:K"), .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

problem is the date keeps on popping up to the right of the edited cell.
I would like to be able to monitor two columns ie, J:K, and the timestamp to
show up in the same row but in column L. Is there a way to do it? I'm
really preetty new at VBA and any help would be much appreciated. Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timestamp ? elroyerni Excel Discussion (Misc queries) 2 June 1st 07 12:07 AM
Timestamp PS Excel Discussion (Misc queries) 2 January 10th 07 02:21 PM
Timestamp Sher Excel Discussion (Misc queries) 2 November 3rd 06 04:31 PM
Now as timestamp Lp12 Excel Worksheet Functions 5 August 13th 06 11:32 AM
Timestamp Macro alexfthe Excel Worksheet Functions 1 March 12th 06 11:39 PM


All times are GMT +1. The time now is 04:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"