I can't assign a macro to a button.

dragontbone

New Member
Joined
Sep 28, 2022
Messages
37
Office Version
  1. 365
Platform
  1. Windows
I have a macro that I want to assign to a button, but when I right-click>assign macro, the name of the macro won't show on the list. I have macros enabled in the trust center, and, this is the only workbook open. I can see the macro in the VBA editor, and it is under the right module in the correct VBA project. I have tried to close Excel, then re-opening it, re-starting my computer, and disabling then re-enabling macros in the trust center. I am not sure what else I can do.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Is the button a Form Control button or on ActiveX Control button?

Can you post the first row of the procedure you are trying to assign the button (the one that contains the name and any parameters)?

And you can tell us the name of the VBA module the procedure resides in?

Also make sure that you have the "Macros in:" option set properly, to include the workbook that the procedure resides in:
1697635610528.png
 
Upvote 0
Is the button a Form Control button or on ActiveX Control button?

Can you post the first row of the procedure you are trying to assign the button (the one that contains the name and any parameters)?

And you can tell us the name of the VBA module the procedure resides in?

Also make sure that you have the "Macros in:" option set properly, to include the workbook that the procedure resides in:
View attachment 100572
I have only ever used form control buttons as I am unsure how to assign a macro to the activex buttons. I also made a shape and tried to assign a macro and was unable to assign a macro to it as well if that helps.

Here are screenshots of what I am seeing both in the assign macro pop up box, and the VBA code editor:
 

Attachments

  • Screenshot 2023-10-18 083015.png
    Screenshot 2023-10-18 083015.png
    8.9 KB · Views: 27
  • Screenshot 2023-10-18 083103.png
    Screenshot 2023-10-18 083103.png
    115 KB · Views: 27
Upvote 0
Have a look here: MACRO'S HAVE DISAPPEARED BUT ARE STILL IN VBA

If none of this helps, you may have a corrupted workbook. In that case, you may need to create a new workbook, and copy all your VBA code to that and use that instead.
Thanks for the link. It gave me the idea to try to compile the file. I have no idea why that worked, but thank you!
 
Upvote 0
Solution
Excellent!
Glad to here you got it fixed, and thank you for posting back how you were able to resolve it.
 
Upvote 1

Forum statistics

Threads
1,223,986
Messages
6,175,793
Members
452,670
Latest member
nogarth

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