Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / March 2008

Tip: Looking for answers? Try searching our database.

TIME STAMP FOR A RANGE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FARAZ QURESHI - 27 Mar 2008 09:51 GMT
I found the following code at http://www.mcgimpsey.com/excel/timestamp.html 
quite useful.

The only question is that how to make it work if a series is entered if a
collection/range is changed?
e.g.
1. Selecting A2:A15, entering xyz and hitting Ctrl+Enter; OR
2. Copying xyz from some other place and pasting/filling all the range in a
single stroke?:

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

Signature


Best Regards,
FARAZ A. QURESHI

Mike H - 27 Mar 2008 10:06 GMT
Hi,

Deleting this line should do it
If .Count > 1 Then Exit Sub

Mike

> I found the following code at http://www.mcgimpsey.com/excel/timestamp.html 
> quite useful.
[quoted text clipped - 23 lines]
>     End With
> End Sub
Gary''s Student - 27 Mar 2008 10:09 GMT
Just remove this line:

If .Count > 1 Then Exit Sub

Signature

Gary''s Student - gsnu200775

Dave Peterson - 27 Mar 2008 12:19 GMT
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
   Dim myCell As Range
   Dim myRng As Range
   
   With Target
       Set myRng = Intersect(.Cells, Me.Range("a2:a15"))
       If myRng Is Nothing Then
           Exit Sub
       End If
   
       For Each myCell In myRng.Cells
           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
       Next myCell
   End With
End Sub

> I found the following code at http://www.mcgimpsey.com/excel/timestamp.html
> quite useful.
[quoted text clipped - 28 lines]
> Best Regards,
> FARAZ A. QURESHI

Signature

Dave Peterson

Dave Peterson - 27 Mar 2008 14:22 GMT
I have a mistake in this code.

Use this instead:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
   Dim myCell As Range
   Dim myRng As Range

   Set myRng = Intersect(Target, Me.Range("a2:a15"))

   If myRng Is Nothing Then
       Exit Sub
   End If
   
   For Each myCell In myRng.Cells
       With myCell
           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 With
   Next myCell
End Sub

> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
[quoted text clipped - 58 lines]
>
> Dave Peterson

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.