Macros set to a control button

What is the code for clicking on a control button in excel that runs a macro?
mlouie23Asked:
Who is Participating?
 
andyclapConnect With a Mentor Commented:
You'll need to change the code for the event handler to be public, eg

Public Sub CommandButton1_Click()


then you can use
worksheetname.Commandbutton1_Click

from anywhere within the workbook
0
 
vbWayneCommented:
Shell "C:\Program Files\Microsoft Office\Office\WINWORD.EXE /yourmacroname", 1
0
 
mlouie23Author Commented:
Edited text of question.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
mlouie23Author Commented:
Hi vbWayne,
    Thanks for the help, but I'm sorry, I wasn't specific enough with my question.

     I've got a conrol button on one worksheet, and I want to run a macro within the same file on a different worksheet.  Does the line of code require to have "C:\Program Files\...etc?"
  Is there there a command/code more specific in excel?
0
 
vbWayneCommented:
 
not sure on that one..I only have bits of code I've collected here and there..the code I gave you opens excel, a file, and runs a macro.


0
 
mlouie23Author Commented:
andyclap,

    Thanks so much for your knowledge!
It helped me a lot.

Take Care,

mlouie23
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.