Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CTRL +BREAK
Is there a way to create a button that stops a series of "iterations" - the
equivalent of CTRL+BREAK how? Moiz |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
CTRL +BREAK
Here is a simple example:
Public Interrupt As Boolean Public Sub TEST() Interrupt = False For i = 1 To 30000 If Interrupt Then Exit For Range("A1").Value = i DoEvents Next i End Sub Sub Button1_Click() Interrupt = True End Sub Key elements: - Public variable that gets set to a particular value when button pressed - In your sub containing the loop you need to "preset" the value of the variable so the loop will run - Important! Include a DoEvents statement inside the loop. Without it the button press will not be detected until the loop ends. - Have some way of terminating the loop when the value of the public variable gets set by the button. Above I use an Exit For statement, but personally I don't like that approach (I am an old-time structured programmer). I prefer to do a While loop in the form of: While .... And Not Interrupt. ' loop code Wend - -- - K Dales "Moiz, ABAC UK" wrote: Is there a way to create a button that stops a series of "iterations" - the equivalent of CTRL+BREAK how? Moiz |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Ctrl+Alt+Break | Excel Programming | |||
Can Not Get Macro to Break with CTRL-BREAK | Excel Programming | |||
How to disable Ctrl+Break | Excel Programming | |||
Stopping a macro without using Ctrl Break | Excel Programming | |||
How to disable the Ctrl+Break ? | Excel Programming |