Q:

Stop macro from repeating when using Application.OnTime

By using the below code RefreshData I run mg macro every 10 secs.
I'm unable to stop stoprefresh which is assigned to a square shape.
Sub RefreshData()
    Application.OnTime Now + TimeValue("00:00:10"), "mg", , True
End Sub

Sub stoprefresh()
    On Error Resume Next
    Application.OnTime Now + TimeValue("00:00:10"), "mg", , False
End Sub

Sub mg()

    ActiveSheet.Cells(ActiveSheet.Cells.Rows.Count, 1).End(xlUp).Offset(1) = "Running"

    Call RefreshData

End Sub

A:

Try this code
Option Explicit

Dim iTimerSet As Double
Sub RefreshData()
    iTimerSet = Now + TimeValue("00:00:10")
    Application.OnTime iTimerSet, "mg", , True
End Sub
Sub stoprefresh()
    'On Error Resume Next
    Application.OnTime iTimerSet, "mg", , False
End Sub

Sub mg()
    ActiveSheet.Cells(ActiveSheet.Cells.Rows.Count, 1).End(xlUp).Offset(1) = "Running"
    Call RefreshData
End Sub

Cancelling a scheduled Procedure 
  It is possible to cancel a procedure that has been scheduled to run but you need to know the
  exact date and time it was scheduled for. To cancel a scheduled
  procedure you must know the "EarliestTime" it was scheduled for.
  Exactly the same syntax except you set the schedule paramater to
  False. This tells the application to cancel the schedule.

