macro boxes: toggle on/off

P

Peter

Hello there, I have created a box with a macro assigned to it and I can click
it to run the macro but I would also like to be able to click it off, I've
seen this done before.

How can I do this? Is there some code to put into the already existing code
for that option?

Thanks...Peter
 
P

papou

Hello Peter
Use the Toggle button control from the Controls tool box.
And use its Value property True / False to either Run / Not Run your macro.
eg:
Private Sub ToggleButton1_Click()
'Toggle is on : run my macro
If ToggleButton1.Value Then
'your macro to run
Macro1
'Toggle is off, exit code
Else: Exit Sub: End If
End Sub

HTH
Cordially
Pascal
 
Top