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!!! |
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!!! |
All times are GMT +1. The time now is 09:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com