Macros set to a control button

What is the code for clicking on a control button in excel that runs a macro?
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

from anywhere within the workbook
Shell "C:\Program Files\Microsoft Office\Office\WINWORD.EXE /yourmacroname", 1
mlouie23Author Commented:
Edited text of question.
Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.

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?
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.

mlouie23Author Commented:

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

Take Care,

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.