Youve created a simple macro and want to assign the macro to a button on a worksheet. In todays question, someone is trying to assign a macro to a button, but it is not working. She can assign the macro to a text box and it works, but not with a button. Episode 594 shows how to assign a macro to a text box, an AutoShape, or a button on the Forms toolbar.
This blog is the video podcast companion to the book, Learn Excel from MrExcel. Download a new two minute video every workday to learn one of the 277 tips from the book!
This blog is the video podcast companion to the book, Learn Excel from MrExcel. Download a new two minute video every workday to learn one of the 277 tips from the book!
Transcript of the video:
Hey, welcome back to the MrExcel netcast.
I'm Bill Jelen.
Another question that came in a power Excel seminar.
First was trying to assign a macro to run from a button and they said I can't get this to work there's nothing I can do.
I can get it to run from a text box or from any bit of auto shapes or anything like that, but it won't work when I try and run it from a button.
Well, that was really strange that would work from a text box or an auto shape.
You know, generally it's, it's pretty easy to set up a macro to run. We might have an auto shape there.
Basically, just right-click and say assign macro and we can assign the macro to run any time someone clicks on that shape.
So, now of course what you would want to do is add some text to that shape or some color or something to make it look like a button, but it's really much better just to use the button that's built into Excel and I pointed out that if we go to View, Toolbars, there's two different areas that have a button There's a control toolbox.
The control toolbox has a bunch of different controls along with one that is called a Command Button.
If I draw this on the sheet you'll see that it looks like a button, but you can't just assign a macro to that command button what we have to do is go to View, Toolbars, and say we want to see the Forms Toolbar.
The Forms Toolbar is much older, but actually simpler to use there's a button there when we choose that button and drag on the sheet.
It actually comes right up and says hello, hey, what macro do you want to assign click OK and we'll add some text there that says, Run Macro.
So, I guessed that probably what's happening is they were trying to use a command button instead of just a button the icons look exactly the same you have to see whether you're in the forms toolbar or the control toolbar to figure out whether you're getting the old style button easy to use or the new style command button harder to use.
So, if you're having problems, assigning a macro to a button just make sure to use the forums toolbar you'll be good to go.
Hey Thanks for stopping by.
We'll see you next time for another netcast from MrExcel.
I'm Bill Jelen.
Another question that came in a power Excel seminar.
First was trying to assign a macro to run from a button and they said I can't get this to work there's nothing I can do.
I can get it to run from a text box or from any bit of auto shapes or anything like that, but it won't work when I try and run it from a button.
Well, that was really strange that would work from a text box or an auto shape.
You know, generally it's, it's pretty easy to set up a macro to run. We might have an auto shape there.
Basically, just right-click and say assign macro and we can assign the macro to run any time someone clicks on that shape.
So, now of course what you would want to do is add some text to that shape or some color or something to make it look like a button, but it's really much better just to use the button that's built into Excel and I pointed out that if we go to View, Toolbars, there's two different areas that have a button There's a control toolbox.
The control toolbox has a bunch of different controls along with one that is called a Command Button.
If I draw this on the sheet you'll see that it looks like a button, but you can't just assign a macro to that command button what we have to do is go to View, Toolbars, and say we want to see the Forms Toolbar.
The Forms Toolbar is much older, but actually simpler to use there's a button there when we choose that button and drag on the sheet.
It actually comes right up and says hello, hey, what macro do you want to assign click OK and we'll add some text there that says, Run Macro.
So, I guessed that probably what's happening is they were trying to use a command button instead of just a button the icons look exactly the same you have to see whether you're in the forms toolbar or the control toolbar to figure out whether you're getting the old style button easy to use or the new style command button harder to use.
So, if you're having problems, assigning a macro to a button just make sure to use the forums toolbar you'll be good to go.
Hey Thanks for stopping by.
We'll see you next time for another netcast from MrExcel.