How to Start a Macro by physically checking a check box?

  • Thread starter Mr Imnotabrainsurgeon
  • Start date
M

Mr Imnotabrainsurgeon

I have created my first macro (don't laugh) and I want the macro to start
when I check off a check box in the form I made.

How do I do this?
 
F

FSt1

hi
try this......
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Call myfirstmacro
End If
End Sub

change any names if needed.
regards
FSt1
 
M

Mike H

If you'e written your macro you can right click your checkbox and assign the
code to it (Forms checkbox) then add this as the first line of your sub

Sub YourSub()
If ActiveSheet.CheckBoxes("Check Box 1").Value = xlOff Then Exit Sub
'Your code
End Sub

Mike
 
S

Susan

when you're in design mode, making changes to the userform, double-
click on the checkbox you want to call the macro. this will open the
VB editor & you will see something like:

Private Sub Checkbox1_Click()
*****
End Sub

except there won't be any stars there. where the stars are, that's
where you code goes. if your code is in a module in the project or in
the userform module you simply write:

Call MyCode '<--- change to the name of your code

and it will make that code run.
:)
susan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top