#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default control box

I would like to set up a control box that runs 1 macro when it is checked and
a different macro when I uncheck it...any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default control box

Ultimately you can only run one macro from a check box. That being said the
macro can decide which code to run based on the value of the checkbox. Now
the question is what type of checkbox do you have on your sheet. If the
checkbox came from the forms toolbar then when you right click the check box
one of the options will be assign macro. If it came from the Control Toolbox
then it will not have assign macro. The code will depend on the type of
checkbox. Reply back and we can supply you with the appropriate code. Also
supply the names of the 2 different macros that you have and which one should
run based on the check mark...
--
HTH...

Jim Thomlinson


"DB74" wrote:

I would like to set up a control box that runs 1 macro when it is checked and
a different macro when I uncheck it...any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default control box

I put a checkbox from the Forms toolbar on the worksheet. I assigned that
checkbox the first macro:

Option Explicit
Sub RunTheMacros()
Dim CBX As CheckBox

Set CBX = ActiveSheet.CheckBoxes(Application.Caller)

If CBX.Value = xlOn Then
Call ItsCheckedMacro
Else
Call ItsNotCheckedMacro
End If
End Sub
Sub ItsCheckedMacro()
MsgBox "Checked"
End Sub
Sub ItsNotCheckedMacro()
MsgBox "Not checked"
End Sub

DB74 wrote:

I would like to set up a control box that runs 1 macro when it is checked and
a different macro when I uncheck it...any suggestions?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default control box

Thanks Jim...I ended up piecing a few comments together and came up with
this...

Private Sub CheckBox1_Click()
If CheckBox1 Then
Application.AutoCorrect.AddReplacement What:=".", Replacement:=":"
Else
Application.AutoCorrect.DeleteReplacement What:="."
End If
End Sub

It seems to work well...

Thanks.

"Jim Thomlinson" wrote:

Ultimately you can only run one macro from a check box. That being said the
macro can decide which code to run based on the value of the checkbox. Now
the question is what type of checkbox do you have on your sheet. If the
checkbox came from the forms toolbar then when you right click the check box
one of the options will be assign macro. If it came from the Control Toolbox
then it will not have assign macro. The code will depend on the type of
checkbox. Reply back and we can supply you with the appropriate code. Also
supply the names of the 2 different macros that you have and which one should
run based on the check mark...
--
HTH...

Jim Thomlinson


"DB74" wrote:

I would like to set up a control box that runs 1 macro when it is checked and
a different macro when I uncheck it...any suggestions?

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
Format Control dialog box control tab softwaregood Excel Discussion (Misc queries) 1 August 23rd 07 04:26 PM
Control tab does not appear in format control dialogue box Phunky E Excel Discussion (Misc queries) 1 June 1st 07 04:05 PM
Control End Jaleel Excel Discussion (Misc queries) 3 September 23rd 06 04:34 PM
spinner format control has no control tab AJ Excel Worksheet Functions 4 March 5th 06 10:30 AM
Control Tab from Combo box- format control missing!! Mo Excel Discussion (Misc queries) 3 January 7th 05 01:09 PM


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