Create A Stopwatch in Excel

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,036
Office Version
  1. 2016
Platform
  1. Windows
Hello To All,

How can i input a stopwatch in excel sheet with a Start, Stop, and Reset Button....

Awaiting reply,

Humayun
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,036
Office Version
  1. 2016
Platform
  1. Windows
Thanks Vog

I will have a loot at it now and will let you know shortly

Regards,

Humayun
 

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,036
Office Version
  1. 2016
Platform
  1. Windows
Dear Vog

I just downloaded the file.... But, i want a stopwatch with a Start, Stop and Reset button on the sheet...

Whereas, the one you told me is without any buttons and also i am unable to stop it...

Can u help me??

Humayun
 

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,036
Office Version
  1. 2016
Platform
  1. Windows
Dear Vog,

Pls let me know that is it possible to have a stopwatch through Vba

Like if we can create 3 command buttons. (1, START 2,STOP 3,RESET)
and then can assign some codes to that so we can have the stop watch on the sheet

Is is possible??? Can u help me with the codes?

Humayun
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650

ADVERTISEMENT

Try in a regular module

Code:
Dim NextTick As Date, t As Date

Sub StartClock()
t = Time
Call TickTock
End Sub

Private Sub TickTock()
Range("A1").Value = Format(Time - t, "hh:mm:ss")
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "TickTock"
End Sub

Sub StopClock()
Application.OnTime earliesttime:=NextTick, procedure:="TickTock", schedule:=False
End Sub

Sub Reset()
Call StopClock
Range("A1").Value = 0
End Sub

You can assign StartClock, StopClock and Reset to buttons from the Forms toolbar.
 

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,036
Office Version
  1. 2016
Platform
  1. Windows
Dear Vog,

I have pasted the codes in the regular module.. Now i have also created three button on the screen named START STOP and RESET..

Pls tell me what to do further ???

i am unable to proceed without your help

Humayun
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Right click each button in turn and select Assign Macro and assign the appropriate sub. Then click the start button to start the stopwatch which is displayed in A1.
 

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,036
Office Version
  1. 2016
Platform
  1. Windows
Dear Vog,

Thanks very much for your help. One last question the time i am getting on the screen is for example 0:00:02 can we increase the second to mili seconds like 0:00:000002

Humayun
 

Watch MrExcel Video

Forum statistics

Threads
1,130,119
Messages
5,640,218
Members
417,131
Latest member
Seanr19871

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top