Assign a Macro to a Button

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have buttons on tabs (created from the toolbox) that I want to assign Macros to. I can click the button go to "Assign Macro" and assign the macro I want. But when I go back to the Button it doesnt have a macro assigned to it. This is happening on several tabs on several buttons (all of them). I saved, opened closed excel, the same thing keeps occuring. I even created new buttons and it happens to them as well.

Why is this happening?

Thanks
Greg
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You usually have to right-click to assign the macro. After you assign it, will the button work right afterwards? Try running the macro without the button to make sure that's not it.
 
Upvote 0
For buttons from the Control Toolbox, right-click the button and select View Code. That's because they have a Click event with a defined signature that is processed by the sheet module.

That said, I'm inclined to use buttons from the Forms Toolbar or autoshapes rather than ActiveX buttons; they have fewer bad behaviors. In that case, you do indeed right-click and select Assign Macro.
 
Upvote 0
Right clicking did the trick.

To answer the other question, yes I did run the code so I know it wasnt anything in the code doing it.

Once I did a right click on buttons, it let me assign the macros and they stuck!

THANKS!
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top