+ Reply to Thread
Results 1 to 5 of 5

"Emergency" stop

  1. #1
    Registered User
    Join Date
    11-20-2006
    Posts
    5

    "Emergency" stop

    Hello,

    my excel sheet runs through a lot of calculations, opens Flowmaster, a simulations program, passes on data, receivs data and so on.
    Is there any way to have a user input to stop the whole simulation.
    During the first tries I had a lot of break point in my debugger, so this helped.
    But now I want to have a button to hit or better just some keys to hit to stop it without using the ctrl+alt+del which closes everything.

    I would appreciate every suggestion!

    Best Regards,
    BeRo

  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282

    To halt execution manually

    Try using the key combination CTRL + BREAK

    Hope this helps,
    theDude

  3. #3
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360
    assign following code to two buttons:

    run the continous loop.
    you can now stop the continous loop using the emeergencyend proc

    HTH
    matt.

    Sub ContinuousLoop()
    Dim x As Integer

    x = 1

    Do Until x = 0
    DoEvents
    Loop
    End Sub

    Sub EmergencyEnd()
    End
    End Sub

  4. #4
    Registered User
    Join Date
    11-20-2006
    Posts
    5
    ok, so far this is not exactly what I am looking for and furthermore I couldn't actually get it to run. let me describe my problem a little bit more in detail:

    the excel sheet has a start button.
    after clicking it, it will run through a lot of rows with data.
    in each row data is passed on to another program, which is opened by the VBA code. then the data is passed back to excel and excel will run two solvers. after that it might do the whole row again if a certain error is too far off.
    so all in all I want to run the whole simulation by just hiting one button and then go and get a coffee or talk to some colleagues.
    But I also want to be able to abort the whole process without loosing any calculated data or closing the excel program.

    my goal would be just to hit some keys on the keyboard and the calulations immediately stopps.

  5. #5
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Hi Bero,

    Matt already gave the solution. You just need to work with it a bit to make it fit your situation.

    Immediately stop? Maybe not. But, all you need in your routine is something that checks to see if you have pressed the stop button.

    Let me re-write Matt's code and see if I can make it more clear how this works.

    I put this code in a general code module:

    Please Login or Register  to view this content.
    And this code on the sheet that has a "start" and a "stop" button ...

    Please Login or Register  to view this content.
    You click on button 1 (start) and the infinite loop proceeds. You click on button 2 and it changes the value of x to make the loop stop.

    Instead of x an integer, maybe you would want to use a boolean. But, the point it, make it a global variable (that is, one defined as Public in the declarations section of a general code module). Then, at key points in your routine be sure to put in the DoEvents statement (to allow Excel to recognize the Stop button was pressed). And, check to see if the value of the "stop" variable has changed.

    I have similar long-running operations in Excel and Access that use this technique. It works.

+ 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