![]() |
Macro Toggle On/Off
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 |
Macro Toggle On/Off
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 '<<============= --- Regards, Norman "Chipmunk" wrote in message ... 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 |
Macro Toggle On/Off
Private Sub ToggleButton1_Click() If ToggleButton1 = True Then 'Call YourMacro1 Exit Sub Else 'Call YourMacro2 Exit Sub End If End Sub Chipmunk Wrote: Hello, how can I execute two different macros from a single toggl 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... Thank -- Ikaabo ----------------------------------------------------------------------- Ikaabod's Profile: http://www.excelforum.com/member.php...fo&userid=3337 View this thread: http://www.excelforum.com/showthread.php?threadid=54223 |
Macro Toggle On/Off
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 --- Regards, Norman |
Macro Toggle On/Off
Thanks, that did it. Well I changed MsgBox to Call. Thanks again.
"Norman Jones" wrote: 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 '<<============= --- Regards, Norman "Chipmunk" wrote in message ... 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 |
All times are GMT +1. The time now is 06:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com