Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Start/Stop Macro Button


I have a macro that runs continuously w/ a timer, however I would like
to be able to start and stop it with a button. I can't seem to get the
Toggle Buttong to do this. Any help?
TIA
Paul


--
Paul987
------------------------------------------------------------------------
Paul987's Profile: http://www.excelforum.com/member.php...o&userid=24850
View this thread: http://www.excelforum.com/showthread...hreadid=559907

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Start/Stop Macro Button

Seeing your Toggle Button's code would help. But in the meantime, here is
code using 2 buttons and a module-wide visible 'switch' you can start with
one button and stop with the other - but note, as written nothing to stop
person from hitting "Start..." button before time is up and starting it over,
giving themself more time. Note that this code will not compile/run because
"TimeIsUp" is undefined - I just used that as a placeholder.

Option Explicit
Dim StopTimer As Boolean

Sub Button1_Click()
TimeIsUp = False
'clicking this button starts the timed event
StopTimer = False
Do Until TimeIsUp Or StopTimer = True
'looping inside timer loop
'the "TimeIsUp" would be the conditions
'you've set up to indicate out of time
DoEvents
Loop
MsgBox "Time is up or you Stopped It"
End Sub

Sub Button2_Click()
'simply set the flag to True
StopTimer = True
End Sub


"Paul987" wrote:


I have a macro that runs continuously w/ a timer, however I would like
to be able to start and stop it with a button. I can't seem to get the
Toggle Buttong to do this. Any help?
TIA
Paul


--
Paul987
------------------------------------------------------------------------
Paul987's Profile: http://www.excelforum.com/member.php...o&userid=24850
View this thread: http://www.excelforum.com/showthread...hreadid=559907


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
Creating a macro that simulates some of the toolbar button Duangruthai New Users to Excel 1 April 22nd 06 12:12 AM
Custom Toolbar Button No Longer Runs Assigned Macro Bryan Excel Discussion (Misc queries) 1 April 10th 06 06:02 PM
Button not bring up Macro I created A.S. Excel Discussion (Misc queries) 1 July 22nd 05 10:21 PM
Assign a macro to Command Button Object dallin Excel Discussion (Misc queries) 2 July 13th 05 03:50 AM
Assigning a macro to a "button" Yvon Excel Discussion (Misc queries) 6 February 8th 05 10:58 PM


All times are GMT +1. The time now is 05:43 PM.

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"