PDA

View Full Version : Buttons to Start and Stop Macro



nitzbar
08-13-2009, 03:55 PM
Hi,

How can I create buttons to start or stop VBA macros from the excel spreadsheet ?

Thx

Bob Phillips
08-13-2009, 04:21 PM
You can use a button form the forms toolbar to start the macro, but you cannot (easily) have a b utton to top it, as it will work through to its conclusion.

mdmackillop
08-14-2009, 05:55 AM
Maybe something like

Dim Test As Boolean

Private Sub CommandButton1_Click()
Test = True
Range("a1") = 0
Do Until Test = False
Range("a1") = Range("a1") + 1
DoEvents
Loop
End Sub

Private Sub CommandButton2_Click()
Test = False
End Sub