#1   Report Post  
Posted to microsoft.public.excel.newusers
tom tom is offline
external usenet poster
 
Posts: 570
Default Time

I need to be able to click on a cell and have it be populated with the
current HH:MM:SS. I know ctrl+shift+; will do the job but I need it to be
even more simple than that for the end users.
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 4,624
Default Time

One way:

Put this in the worksheet code module (right-click the worksheet tab and
choose View Code):

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
With Range("J1")
If Not Intersect(Target, .Cells) Is Nothing Then
.Value = Time
.NumberFormat = "HH:MM:SS"
End If
End With
End Sub

or, if you only want it to update once:


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
With Range("J1")
If Not Intersect(Target, .Cells) Is Nothing Then
If IsEmpty(.Value) Then
.Value = Time
.NumberFormat = "HH:MM:SS"
End If
End If
End With
End Sub

Note that this will also fire if the user presses an arrow key to enter
the cell. If you'd rather, you can use a double-click:


Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
With Range("J1")
If Not Intersect(Target, .Cells) Is Nothing Then
If IsEmpty(.Value) Then
.Value = Time
.NumberFormat = "HH:MM:SS"
Cancel = True
End If
End If
End With
End Sub



In article ,
Tom wrote:

I need to be able to click on a cell and have it be populated with the
current HH:MM:SS. I know ctrl+shift+; will do the job but I need it to be
even more simple than that for the end users.

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
straight time, time and a half, and double time Jeremy Excel Discussion (Misc queries) 3 September 23rd 08 09:03 PM
Calculate Ending time using Start Time and Elapsed Time Chief 711 Excel Worksheet Functions 5 May 13th 08 04:34 PM
verify use of TIME Function, Find Quantity Level compare to time-d nastech Excel Discussion (Misc queries) 9 July 11th 07 01:58 PM
template or formula for start time -finish time -total hours ple cc New Users to Excel 1 March 27th 06 06:06 PM
Calculating days & time left from start date/time to end date/time marie Excel Worksheet Functions 7 December 7th 05 02:36 PM


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