Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Timer | Excel Worksheet Functions | |||
VBA Timer | Excel Programming | |||
Timer | Excel Programming | |||
Stopping a Timer / Running a timer simultaneously on Excel | Excel Discussion (Misc queries) | |||
Timer | Excel Programming |