Using Checkboxes

  • Thread starter Thread starter Mischa
  • Start date Start date
M

Mischa

Good day,



I have a commandbutton placed in my workbook.

If you press the button sub MyDozen will be called.



Now I want this commandbutton to have two functions.



So either sub MyDozen is called or sub MyBoots is called.



I have placed a checkbox next to the button.

So if the user wants to call the standard sub (MyDozen) than the checkbox
should be un-checked.

If the user wants to call the second sub (MyBoots) is called he should
select the checkbox.



Now what code should I write behind the commanbutton to check if the
checkbox is selected?







Tks,

mischa
 
Why make life so complicated! Have two commandbuttons and
assign the macros seperately. Cheers.
 
The commandbutton is from the control toolbox toolbar placed on a worksheet?

If yes, then I put this under that worksheet:

Option Explicit
Private Sub CommandButton1_Click()

If Me.CheckBox1.Value = True Then
Call MyBoots
Else
Call MyDozen
End If

End Sub

And these in a general module.

Option Explicit
Sub MyBoots()
MsgBox "from MyBoots"
End Sub
Sub MyDozen()
MsgBox "from myDozen"
End Sub
 
Back
Top