Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Entering (NOW) information on click

Is there any way to put code in the WorkBook Module so that when a person
clicks on a cell (and only when they click on this cell) on any sheet, it
would put in the current time and date?
--
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Entering (NOW) information on click

Not really. Excel doesn't have a _Click event.

But you could use the Workbook_SheetSelectionChange event (which would fire if
you moved the cursor to that cell) or the Workbook_SheetBeforeDoubleClick event
or even the Workbook_SheetBeforeRightClick event.

I chose to use the _sheetbeforeRightClick in this sample.

Option Explicit
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)

Dim myAddr As String
myAddr = "A1"

If Target.Cells.Count 1 Then
Exit Sub 'one cell at a time!
End If

If Intersect(Target, Sh.Range(myAddr)) Is Nothing Then
'do nothing
Else
Cancel = True 'don't show options???
Application.EnableEvents = False
With Target
.NumberFormat = "mmm dd, yyyy hh:mm:ss"
.Value = Now
End With
Application.EnableEvents = True
End If

End Sub



Howard wrote:

Is there any way to put code in the WorkBook Module so that when a person
clicks on a cell (and only when they click on this cell) on any sheet, it
would put in the current time and date?
--
Howard


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Entering (NOW) information on click


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

If Target.Address = "$H$1" Then

Target.Value = Now()
Target.NumberFormat = "dd mmm yyyy hh:mm:ss"
End If
End Sub


--

HTH

Bob

"Howard" wrote in message
...
Is there any way to put code in the WorkBook Module so that when a person
clicks on a cell (and only when they click on this cell) on any sheet, it
would put in the current time and date?
--
Howard



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Entering (NOW) information on click

Double-click event In Thisworkbook Module

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" And Target.Value < "" Then
Target.Value = Format(Now, "mm/dd/yyyy hh:mm:ss")
End If
Cancel = True
End Sub


Gord Dibben MS Excel MVP

On Fri, 2 Apr 2010 08:23:02 -0700, Howard
wrote:

Is there any way to put code in the WorkBook Module so that when a person
clicks on a cell (and only when they click on this cell) on any sheet, it
would put in the current time and date?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Entering (NOW) information on click

See if this works for you. I used Range("B2"), but you can change that to
whatever you want.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Not Intersect(Target, Range("B2")) Is Nothing Then
Target.Value = Now
End If
End Sub




"Howard" wrote in message
...
Is there any way to put code in the WorkBook Module so that when a person
clicks on a cell (and only when they click on this cell) on any sheet, it
would put in the current time and date?
--
Howard





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Entering (NOW) information on click

Thanks to everyone who answered. We really appreciate you folks.
--
Howard


"JLGWhiz" wrote:

See if this works for you. I used Range("B2"), but you can change that to
whatever you want.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Not Intersect(Target, Range("B2")) Is Nothing Then
Target.Value = Now
End If
End Sub




"Howard" wrote in message
...
Is there any way to put code in the WorkBook Module so that when a person
clicks on a cell (and only when they click on this cell) on any sheet, it
would put in the current time and date?
--
Howard



.

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
Entering information Link[_2_] Excel Programming 5 June 23rd 09 12:50 PM
Entering information Link[_2_] Excel Programming 20 June 3rd 09 10:17 AM
Entering Information Into Another Column Té Excel Discussion (Misc queries) 2 June 25th 08 05:16 PM
Entering data using a mouse click Cheers100 Excel Discussion (Misc queries) 4 January 9th 07 04:03 PM
Mouse Over Graph, Capture Information on Click(Double Click) Dean Hinson[_3_] Excel Programming 1 December 6th 04 04:49 AM


All times are GMT +1. The time now is 10:24 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"