Macro Toggle On/Off

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, how can I execute two different macros from a single toggle button?

Example: I press the toggle button and macro1 executes,
I press the same button again and macro2 executes,
I press the same button again and macro1 executes etc...

Thanks
 
Hi Chipmunk,

Try something like:

'=============>>
Public Sub ToggleIt()
Static blFlag As Boolean

blFlag = Not blFlag

If blFlag Then
'Action 1 e.g.:
MsgBox "Action1"
Else
'Action 2 , e.g.:
MsgBox "Action 2"
End If

End Sub
'<<=============
 
Private Sub ToggleButton1_Click()
If ToggleButton1 = True Then
'Call YourMacro1
Exit Sub
Else
'Call YourMacro2
Exit Sub
End If
End Sub
 
Hi Chipmunk,

Just to add, the demo actions may be calls to discrete macros. So, for
example, the line:
MsgBox "Action1"

might be replaced with the instruction:

Call Macro1
 
Back
Top