Please help me stop my Macro from running..thank you.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
;)The first code is to run the macro and the second code is to stop the 1st macro from running when i click on the button, but when i click on the button with 2nd macro on it, it does not stop the macro.

Please edit the second macro so that when i run the second macro it will stop the 1st macro from running. Thanks alot!


----------------------------

Sub Updateclok()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
' My DIGITAL
ThisWorkbook.Sheets("blabla").Range("DigitalClock").Value = CDbl(Time)<o:p></o:p>

' Set up the next event one second from now<o:p></o:p>
NextTick = Now + TimeValue("00:10:02")<o:p></o:p>
Application.OnTime NextTick, "Updateclok"

End Sub

--------------------------


Sub Stopclk()
' Cancels the OnTime event (stops the clock)
On Error Resume Next
Application.OnTime NextTick, "UpdateClock", , False
End Sub
 

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.
You need to define NextTick at the top of the module, before any subs like this

Code:
Dim NextTick As Date
Sub Updateclok()
' My DIGITAL
ThisWorkbook.Sheets("blabla").Range("DigitalClock").Value = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:10:02")
Application.OnTime NextTick, "Updateclok"

End Sub



Sub Stopclk()
' Cancels the OnTime event (stops the clock)
On Error Resume Next
Application.OnTime NextTick, "UpdateClock", , False
End Sub
 
Upvote 0
Vog, can you please tell me how to define NextTick so that when i run the 2nd macro it stop the first macro???
 
Upvote 0
I dont why but it does not stop the macro when i click on it. There is no error message but it does not stop the time..


Could you please recheck it again?
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,185
Members
448,554
Latest member
Gleisner2

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