Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub CommandButton1_Click()
Dim ctr As Long Dim StartNum As Integer StartNum = 0 Range("B2").Select While StartNum <= 9 Range("B2") = StartNum StartNum = StartNum + 1 While ctr < 600000 ctr = ctr + 1 Wend ctr = 1 If StartNum = 10 Then StartNum = 0 End If Wend End Sub I have two buttons in sheet1, "Start" and "Stop" When I click the "Start" button, it runs the above code and increments value in cell B2 but the mouse loses focus. I want to interrupt the above code when I click the "Stop" button but it does not allow me to click anywhere as the code is in Loop. How can I click the "Stop" button? I got a reply from forums to add "doevents" below ctr = ctr + 1 line to get access to the stop button but the initial macro pauses to enable events on the form. I am looking to multitask both, the loop and the events. Value in cell B2 should keep on incrementing and the moment user clicks on the Stop button, it should stop. Thanks Maxi |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Interrupting Calculation Iterations | Excel Discussion (Misc queries) | |||
Interrupting A Worksheet Calculation | Excel Worksheet Functions | |||
Interrupting an endless loop | Excel Programming | |||
Interrupting a loop | Excel Programming | |||
Interrupting an add line | Excel Programming |