Stop Watch

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
203
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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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