Imbedded buton to run macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I run XL2003
I have designed a button embedded in my worksheet.
I want my new button to run a macro which I recorded.

How do I assign a specific macro to a specific button?

I don't want to customize a button on a menu!
 
Hi Fritz,

You already have the button embedded, so go into Design Mode (on the Visual
Basic toolbar - I expect you are already there considering you have the
button). Then just double click that button and the Visual Basic editor
should open in the worksheet module in the Click Event of the button that you
created:

Private Sub myButton_Click()

End Sub

You can either write your macro code in this sub, or call your macro from it:

Private Sub myButton_Click()
myMacro
End Sub

If your macro is contained in another module, make sure it isn't declared as
Private, or the call from the Worksheet module won't find it. I think, by
default, recorded macros aren't declared and are therefore public anyway.
 

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

Back
Top