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
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Vog, can you please tell me how to define NextTick so that when i run the 2nd macro it stop the first macro???
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,123,291
Messages
5,600,760
Members
414,405
Latest member
Zaurb

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