Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Member
 
Posts: 84
Question Time/Date auto insert upon click

Hey all,

I have set up a left double click command to insert time (code below: "BeforeDoubleClick") in rows C and D and I also have a code that inserts the current date one row to the left of column C. However, when I double click in row C, Excel will insert the current time but the code to insert the date one row to the left is ignored. I can get the date code to function if I insert the time in row C by using the CTRL+SHIFT+Colon keyboard shortcut, but I'd prefer to just double click in Row C like I can in Row D.

What am I missing?

Thanks for your help,
Keyrookie


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("C:C"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, -1).ClearContents
Else
With .Offset(0, -1)
.NumberFormat = "dddd, mm/dd/yy"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub




Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Const MY_RANGE As String = "C:D"
Dim cell As Date
On Error GoTo endit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(MY_RANGE)) Is Nothing Then
Target.Value = Format(Time, "hh:mm AM/PM")
End If
Cancel = True
endit:
Application.EnableEvents = True
End Sub

Last edited by Keyrookie : January 15th 13 at 08:16 PM
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
how do i auto insert a date and time stamp cjensen Excel Discussion (Misc queries) 3 February 6th 07 03:44 AM
Auto insert Date & Time when another cell is populated Trixie Excel Discussion (Misc queries) 1 October 2nd 06 03:59 AM
Auto insert date/time Tino Excel Worksheet Functions 1 September 8th 06 05:58 PM
Auto date/time insert when data entered into an adjacent cell Auto date/time Excel Worksheet Functions 1 July 9th 05 12:10 AM
Auto Date/Time when click on cell MAGICofSeth Excel Programming 3 May 17th 04 02:36 AM


All times are GMT +1. The time now is 06:40 AM.

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"