Stop Watch

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
Dear Group ive got this VBA code

Public Vent As Double

Sub StartTid()
On Error Resume Next
Vent = Now + TimeSerial(0, 0, 1)
Application.OnTime Vent, "StartTid", , True
Range("A1").Value = Format(Time, "hh:mm:ss")
End Sub


Kode for stop ur er:

Sub StopTid()
On Error Resume Next
Application.OnTime Vent, "StartTid", , False
End Sub

This code Works Ok But i need a Funktion
when Time is starte the time Was Copy to B1.
When Time is Stop the time was Copy to B2
and then the Used Time should be in B3 (B2 - B1)

Ive have being searching on google but Did'n find any clue to figure it out

Hope it is enough info

Your regards form me
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hello Hjemmet,

Try this...

Code:
Public Vent As Double


Sub StartTid()
        On Error Resume Next
        Vent = Now + TimeSerial(0, 0, 1)
        Application.OnTime Vent, "StartTid", , True
        Range("B1").Value = Format(Time, "hh:mm:ss")
End Sub


Sub StopTid()
        On Error Resume Next
        Application.OnTime Vent, "StartTid", , False
        Range("B2").Value = Format(Time, "hh:mm:ss")
        Range("B3").Formula = "=B2-B1"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,981
Messages
6,175,768
Members
452,668
Latest member
mrider123

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
Back
Top