Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
stop a macro
hi
i have the ffg macro that uses a label and display it as a clock...... the problem is after the application quits the macro continues and the program re-executes. the code is below............... Sub clock() If ThisWorkbook.Sheets("Client Info").Range("b3").Value = "x" Then Exit Sub frmMainFrame.lblTime.Caption = Format(Now, "hh:mm:ss AM/PM") Application.OnTime Now + TimeSerial(0, 0, 1), "clock" End Sub the first line of code shud stop the macro bt doesn't is there a better manner of doing this? Please Help thanx in advanced!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
stop a macro
I use the below code which I got from someone here in the board...when
terminate the userform I call stoptimer. Hope it helps, Ozgur Public RunWhen As Double Public Const cRunIntervalSeconds = 60 Public Const cRunWhat = "The_Sub" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, schedule:=True End Sub Sub The_Sub() UserForm2.Label475.Caption = Format(Now, "dd mmm yy hh:mm") Call StartTimer End Sub Sub StopTimer() On Error Resume Next Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, schedule:=False End Sub "Zaahir" wrote: hi i have the ffg macro that uses a label and display it as a clock...... the problem is after the application quits the macro continues and the program re-executes. the code is below............... Sub clock() If ThisWorkbook.Sheets("Client Info").Range("b3").Value = "x" Then Exit Sub frmMainFrame.lblTime.Caption = Format(Now, "hh:mm:ss AM/PM") Application.OnTime Now + TimeSerial(0, 0, 1), "clock" End Sub the first line of code shud stop the macro bt doesn't is there a better manner of doing this? Please Help thanx in advanced!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Stop | Excel Worksheet Functions | |||
Macro to stop at a certain tab and does not go to the next one. | Excel Worksheet Functions | |||
Stop running a macro in the middle of a macro | Excel Programming | |||
Macro: With Stop it works. Without Stop it doesn't. | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |