Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Currently i have a stopwatch(SW) created using excel vba. The SW has three buttons, one to start(cmdStart), one to stop(cmdStop), and one to reset(cmdReset). The elapsed time is displayed in a label(Timer). Everything is working good, the SW is accurate, the only problem that i am having is that the SW is only counting in seconds. what i really need is for the SW to count hour:min:sec. I have tried formating Timer to "hh:mm:ss" but vba will not count it. My question is: How can i format Timer to make it work the way i need it to? the code that i am currently using is as fallowed:
Located in Sheet3 (SW location):
Private Sub cmdReset_Click()
Sheet3.Timer.Caption = 0
cmdStart.Enabled = True
cmdStop.Enabled = False
cmdReset.Enabled = True
End SubPrivate Sub cmdStart_Click()
cmdStart.Enabled = False
cmdStop.Enabled = True
cmdReset.Enabled = False
StartTimer
End SubPrivate Sub cmdStop_Click()
cmdStart.Enabled = True
cmdStop.Enabled = False
cmdReset.Enabled = True
End Sub
Located in Module1:Public RunWhen As Double
Public Const cRunWhat = "The_Sub"
Sub StartTimer()
Application.ScreenUpdating = True
RunWhen = Time() + TimeSerial(0, 0, 1)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End SubSub The_Sub()
Sheet3.Timer.Caption = Sheet3.Timer.Caption + 1
If Sheet3.cmdStart.Enabled = False Then _
StartTimer
End Sub
Can some one please help me? I have been working on this for days.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |