+ Reply to Thread
Results 1 to 2 of 2

Start/Stop Macro Button

  1. #1
    Forum Contributor
    Join Date
    07-01-2005
    Posts
    103

    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

  2. #2
    JLatham
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1