System clock start/end button.

Jaloko

New Member
Joined
Dec 14, 2016
Messages
4
So, I know how to make a simple time Variance between times entered manually.

But what I want to do is have a button that you can click and it will grab the time from your System clock, record that in a cell. I suppose I will do the same with the end time as well. I then want to have it record the variance between those 2 times.

I know to do this manually by entering the time but I want to make it easier by simply having it pull the time directly from the system clock using a start button and end button.
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,830
Office Version
  1. 365
Platform
  1. Windows
Make two ActiveX buttons (Developer Tab - Insert - Command Button ActiveX control)
Right click on each and choose properties. Change the Name and the caption for each.
Double click on each button with Designer Mode on
Add the following code just like I did:

Code:
Private Sub StartTime_Click()  
Range("I3") = Now() - Int(Now())
  Range("I4") = Now() - Int(Now())
  
End Sub


Private Sub EndTime_Click()
  Range("I4") = Now() - Int(Now())
End Sub

Turn Designer mode off
In Cel I5 put: =I4-I3
Format cells I3:I5 with this format: h:mm:ss;@

The start button adds the current time to both the Start Time and End Time Cells. The End Time Button puts the current time in the End Time Cell
 
Last edited:

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,378
Code:
Private Sub StartTime_Click()  
Range("I3") = Now() - Int(Now())
  Range("I4") = Now() - Int(Now())
  
End Sub


Private Sub EndTime_Click()
  Range("I4") = Now() - Int(Now())
End Sub

You could replace ...
= Now() - Int(Now())

With...
= Now - Date

Or this...
= Time
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,519
Messages
5,596,634
Members
414,082
Latest member
sasmita

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