Macro won't stop..HELP!

Ardwinn

New Member
Joined
Nov 28, 2016
Messages
24
So several of you helped me with the code below which is designed to track time on a spreadsheet. It is here:

Sub Recalc()With Sheet1.Range("U1")
.Value = Format(Time, "hhmm;@")
End With
Call SetTime
End Sub
----------------------------------------
Sub SetTime()
SchedRecalc = Now + TimeValue("00:00:10")
Application.OnTime SchedRecalc, "Recalc"
End Sub

The code below used to stop the timer, however it's not working and now every 10 seconds the macro runs, even if I close the spreadsheet. Please help fix the code so it will stop the timer:

Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
End Sub

Thank you in advance.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
when using a timer I always use a cell on the worksheet which I set true to enable it and false to disable it. see below:
Code:
Sub Recalc()With Sheet1.Range("U1")
.Value = Format(Time, "hhmm;@")
End With
if cells(1,1) then
Call SetTime
end if
End Sub

Obviously change "Cells(1,1)" tosome spare cell on your worksheet. This won't cancel the timer but it will stop it resetting which if you are triggering every 10 seconds shoujld be ok.
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,123
Members
449,096
Latest member
provoking

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