Multiple VBA with multiple check boxes and one Button

Luka_LB

Board Regular
Joined
Nov 14, 2011
Messages
51
Hi everyone

I'm havin' this issue

i have for e.g. 10 VBA and 10 check boxes and an 'execute' button

so, i want this button execute exactly that vba, which I will select by checking checkbox

Each time there will be only one box checked

also I'll need to have names for boxes like you can see attached picture

and could you please explain more detailed way, because i'm a beginner :)

thank you in advance for your time and help


 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi Luka_LB,

Firstly, you mention that only one checkbox will be checked. This being the case you should be using optionbuttons rather than checkboxes. Optionbuttons enforce that only one option can be selected. The following will work with either checkboxes or optionbuttons, but be aware that if multiple checkboxes are checked only the first (top) one will be run.

I recommend that you name each optionbutton (using the Name property of each optionbutton) to make the code clearer. In this code I named three optionbuttons WriteOB, ErazeOB, and DivideOB. Note that I also named the Execute commandbutton ExecuteCB. Also note that in this code the statement

If WriteOB Then

is equivalent to

If WriteOB.Value = True Then

where the Value property of the optionbutton yields True if the option is selected, False otherwise.

Put this code in the commandbutton's Click event like this.

Code:
Private Sub ExecuteCB_Click()
   If WriteOB Then
      MsgBox "Run Write macro"
   ElseIf ErazeOB Then
      MsgBox "Run Eraze macro"
   ElseIf DivideOB Then
      MsgBox "Run Divide macro"
   'add ElseIF statements for remaining optionbuttons here
   End If
   
   Unload Me 'this unloads the form when done
End Sub

Simply replace each MsgBox statement with the macro name that you want to run for that option.

Keep Excelling.

Damon
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top