Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle between two workbooks via MACRO Aligi Excel Discussion (Misc queries) 2 July 8th 08 08:43 PM
macro boxes: toggle on/off Peter Excel Discussion (Misc queries) 1 October 5th 07 09:34 AM
Toggle comments on or off macro Jim G Excel Discussion (Misc queries) 3 October 5th 06 04:07 AM
Toggle Macro Michael Excel Programming 5 June 11th 04 03:18 PM
Toggle Macro with KeyStrokes Cesar Zapata[_2_] Excel Programming 0 November 13th 03 05:07 PM


All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"