Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default time stamp capturing

hi there,
I would like to be able to select a cell and type a number in it from 1-9.
When the number is entered i would like excel to record the time in that
cell. ie if i type 5 in cell B9 it automatically records the current time ie
10:57 in B9. Note the 5 is replaced with the recorded time. This time also
has to be fixed and cannot be changed, when i click on the next cell. This is
to record start and finish times in sheet.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default time stamp capturing

Does it really matter what the number is that you enter?
try this Worksheet Event Code
Right Click on the Sheet Tab and select View Code.
Paste this code there.
Whenever you change a cell in the range A1:B10, the Code will change
the cell into the current time

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then Target =
Time
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default time stamp capturing

You should disable events in the code:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
Target =Time
End If
Application.EnableEvents = True
End Sub

Otherwise, the code will change a cell, which triggers _Change, which
changes a cell, which triggers _Change, which changes a cell, which
triggers _Change and on and on until VBA terminates the loop when it
runs out of stack space.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Sat, 7 Feb 2009 02:30:36 -0800 (PST), CurlyDave
wrote:

Does it really matter what the number is that you enter?
try this Worksheet Event Code
Right Click on the Sheet Tab and select View Code.
Paste this code there.
Whenever you change a cell in the range A1:B10, the Code will change
the cell into the current time

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then Target =
Time
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default time stamp capturing

On Feb 7, 10:45*am, Chip Pearson wrote:
You should disable events in the code:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
* * * * Target =Time
End If
Application.EnableEvents = True
End Sub

Otherwise, the code will change a cell, which triggers _Change, which
changes a cell, which triggers _Change, which changes a cell, which
triggers _Change and on and on until VBA terminates the loop when it
runs out of stack space.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
* * Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLCwww.cpearson.com


That makes total sense, interestingly that annoying loop does not
happen on my worksheet
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
Extracting the Time from a Date/Time Stamp agilek9 Excel Programming 2 November 20th 08 05:34 PM
Date Capturing by Time Ken Excel Discussion (Misc queries) 1 December 2nd 07 10:50 AM
Comparing 2 files on date/time stamp, and based time difference do a subroutine [email protected] Excel Programming 1 September 28th 07 03:53 AM
Capturing Time The Excelerator[_2_] Excel Programming 1 February 27th 07 02:22 PM
time stamp a cell that doesn,t change when time stamping another RC Excel Programming 5 October 13th 05 02:52 AM


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

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

About Us

"It's about Microsoft Excel"