Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 ! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi i watched the code from bob now, sorry for the dealy.. it works like i
need ty bob!! i think there is a module for start stopping that can be bypassed just writing 0 in the cell.. then can anybody suggest me some way to display the timer in seconds, maybe just as translation of the first cell..ty also rguy !! "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 ! |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ! |
#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 |
Reply |
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 |