Assigning Macro to a button not working but works when run manually

AnneWeber

New Member
Joined
Sep 11, 2024
Messages
1
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
Hello,

I recorded a macro just clearing inputs in my file that I'm working with and I've inserted a button onto the sheet and done the 'assign macro' step but it doesn't run my macro. I'm not getting any error or anything, the button does nothing. The macro works if run it from the 'View Macro' option on the ribbon but I can't get it to be assigned to the button. I've tried both a button and a shape. I've gotten it to work if I am assigning the macro to the button and titling it 'Workbook name YYYY.xlsm'!Clear (clear is what my macro name is) but if I do it this way and I make edits in the future and rename the workbook, I'm worried the button won't work.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Welcome to the Board!

Does this VBA code reside in the workbook you are trying to run it in, or somewhere else?

What is the name of the module it is stored in?

Can you post the VBA code for this procedure?
See here for how to post your VBA code: How to Post Your VBA Code
 
Upvote 0
Alt-F11 to open VBA project. Click the Sheet in the VBA project model that the Button is on. Top left of the Code window use the drop-down and click on the Button name. Paste code for button there.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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