Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Toggle Button

I have a toggle button that when clicked ON I want to run
one code and when clicked OFF I want to run a different
code. Is this possible?? Please help me out.

--Keri
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Toggle Button

If it is a toolbar button, you can set and check its State property.

If it is a commandbutton, then you could use a global variable and set
/unset that,

Dim fStatus As Boolean

Private Sub CommandButton1_Click()

If fStatus Then
'do one thing
Else
'do an other
End If

fStatus = Not fStatus

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Keri" wrote in message
...
I have a toggle button that when clicked ON I want to run
one code and when clicked OFF I want to run a different
code. Is this possible?? Please help me out.

--Keri



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Toggle Button

Bob told you how to do it with a commandbutton and a forms button.

If it is a toggle button as you imply

Private Sub ToggleButton1_Click()
if ToggleButton1.Value = True then ' depressed
macro1
else
macro2
End if
End Sub

--
Regards,
Tom Ogilvy

"Keri" wrote in message
...
I have a toggle button that when clicked ON I want to run
one code and when clicked OFF I want to run a different
code. Is this possible?? Please help me out.

--Keri



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 Button Squeaky Excel Worksheet Functions 0 September 17th 08 04:14 PM
Toggle Button mick2 Excel Discussion (Misc queries) 5 November 27th 05 05:52 AM
Toggle button keithl816 Excel Discussion (Misc queries) 2 November 21st 05 09:16 PM
Toggle Button Dave_2k5 Excel Discussion (Misc queries) 2 September 1st 05 11:27 AM
Toggle Button Ben E[_2_] Excel Programming 1 October 29th 03 04:42 PM


All times are GMT +1. The time now is 01:35 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"