Help with the tic button, not the comand button

Get_Involved

Active Member
Joined
Jan 26, 2007
Messages
383
This code works with comand buttons.
I have tried to do it with just buttons but can't get it to work.
When I click on a button it starts the timer, when I click on a different button it stops the running timer then starts the next timer.
I need it to work with the tic button not the comand button button.
Can someone tell me or help with rewriting the code Please?

Code:
Option Explicit
Dim StopTimer As Boolean
Private Sub CommandButton1_Click()
  'Start the timer
  Const Minutes = 480
  Dim EndTime As Double
  StopTimer = False
  Do
    If EndTime - Now < 0 Then
      EndTime = Now + TimeSerial(0, Minutes, 0)
    End If
    Range("G7") = EndTime - Now
    DoEvents
  Loop Until StopTimer
End Sub

Private Sub CommandButton3_Click()
  'Start the timer
  Const Minutes = 660
  Dim EndTime As Double
  StopTimer = False
  Do
    If EndTime - Now < 0 Then
      EndTime = Now + TimeSerial(0, Minutes, 0)
    End If
    Range("G10") = EndTime - Now
    DoEvents
  Loop Until StopTimer
End Sub

Private Sub CommandButton5_Click()
  'Start the timer
  Const Minutes = 840
  Dim EndTime As Double
  StopTimer = False
  Do
    If EndTime - Now < 0 Then
      EndTime = Now + TimeSerial(0, Minutes, 0)
    End If
    Range("G13") = EndTime - Now
    DoEvents
  Loop Until StopTimer
End Sub

Private Sub CommandButton7_Click()
  'Start the timer
  Const Minutes = 4200
  Dim EndTime As Double
  StopTimer = False
  Do
    If EndTime - Now < 0 Then
      EndTime = Now + TimeSerial(0, Minutes, 0)
    End If
    Range("G16") = EndTime - Now
    DoEvents
  Loop Until StopTimer
End Sub
 
Last edited by a moderator:

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.

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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