Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Stop LMP Excel Worksheet Functions 3 April 28th 08 07:33 PM
Macro to stop at a certain tab and does not go to the next one. [email protected] Excel Worksheet Functions 3 March 16th 06 01:11 AM
Stop running a macro in the middle of a macro gmunro Excel Programming 3 June 9th 05 06:00 PM
Macro: With Stop it works. Without Stop it doesn't. Don Wiss Excel Programming 2 October 12th 04 10:49 AM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"