Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Timer

I didn't look at those sites.

You may want to take a look at Chip Pearson's notes on .ontime:
http://www.cpearson.com/excel/OnTime.aspx



SJW_OST wrote:

The code on this site is great and could do what I need but how do I set it
to count down from a time of my choosing? Countdown from say 15 minutes or 30
minutes, etc? It keeps starting at 24 hours no matter what I do.

TY for your help.

"ryguy7272" wrote:

Take a look at these:
http://www.planet-source-code.com/vb...34409&lngWId=1

http://www.enhanceddatasystems.com/E...ExcelTimer.htm

Regards,
Ryan--


--
RyGuy


"N+" wrote:


ty bob i will try !



"Bob Phillips" wrote:

Add this to a standard code module

Option Explicit

Public nTime As Double

Public Sub StartTimer()
On Error Resume Next
Application.OnTime nTime, "RunTimer", , False
On Error GoTo 0

ActiveSheet.Range("A1").Value = 0
RunTimer
End Sub

Public Sub StopTimer()
Application.OnTime nTime, "RunTimer", , False
End Sub

Public Sub RunTimer()
With ActiveSheet.Range("A1")
.Value = .Value + TimeSerial(0, 0, 1)
.NumberFormat = "hh:mm:ss"
End With
nTime = Now + TimeSerial(0, 0, 1)
Application.OnTime nTime, "RunTimer"
End Sub

To the appropriate worksheet code module

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value Then
StopTimer
StartTimer
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

and to ThisWorkbook code module


Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub

Private Sub Workbook_Open()
StartTimer
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"N+" wrote in message
...
hi all p !!
i would like to create a timer in seconds displayed in a cell, restarted
if
in another cell the condition is TRUE
ty for help !




--

Dave Peterson
 
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
Timer Vijay Excel Worksheet Functions 1 April 6th 07 11:00 AM
VBA Timer Lisa[_12_] Excel Programming 4 August 8th 06 04:42 PM
Timer Steve Excel Programming 4 June 13th 06 02:23 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
Timer TJ Excel Programming 1 July 9th 04 03:18 PM


All times are GMT +1. The time now is 03:43 AM.

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"