assign macro to button programmatically

Z

Zone

I have a button on my worksheet from the Forms toolbar. I know I can use
ActiveSheet.Buttons(1).Caption="My Text" to set the button's caption. But
how do I set the button's macro to sub SpeakMsg? Excel XP. Thanks, James
 
H

Helmut Weber

Hi Zone

Sub Macro1()
ActiveSheet.Shapes("Button 1").OnAction = "testB"
End Sub


--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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