Running Macros - Ribbon
- 02:59
Understand how to add a Macro button to a ribbon
Downloads
No associated resources to download.
Glossary
Custom Macros New Ribbon Group VBATranscript
So to assign a macro to a new button on a ribbon, then what we need to do is think about where we're gonna position the button, first of all, and we can position them anywhere. Some people like to add them into the appropriate ribbon itself, so they might want to add them into, say, the Insert ribbon, or the Data ribbon, or whatever the command is related to. Other people like to create a new ribbon at the end of the existing set, just purely for their own custom macros. Lots of different ways to go. I'm gonna add my Insert Name macro command at the end of the Insert ribbon, just because I think that's gonna be a place where I'm gonna remember where it is. So to do this, it doesn't matter what ribbon you have open, you just right-click over any of them, and choose Customize the Ribbon.
Over on the commands dropdown list, we're gonna go and choose Macros, which will now list out all the available macros I've got. In the Tabs area here, I just need to expand the area where I'd like to add the macro command into. So as I said, we're gonna put ours in the Insert ribbon, gonna choose Insert. And then at the end here, I want to insert a new group. I can't just insert a macro here. I need to have a group to insert it to. So I'm gonna insert a new group. I'm going to rename that, and we're gonna call it My Macros.
Click, Okay. So now we've got this new group available. I can now go to the available commands, choose the macro that I'd like it to run, and then add that in. And you can see now, it's appeared in the group that I just added. Like before, we can go and rename that. So, let's add some spaces in to make it look a little bit neater. And if I want to change the icon for that particular macro, I can do that as well. Click Okay. And then once I'm done, Okay, out of the whole thing. And now when I go to the Insert ribbon, you'll see we now have our new command, and when I click on that, it's gonna run my macro. Now, if we're gonna be running buttons on our ribbon, and we've modified the ribbon, obviously the ribbon interface is the same, no matter what workbook I have open. So it's important to realize that the kind of macros that you're going to run via ribbon commands, are gonna be macros that you've recorded in the personal macro workbook. Remember, the personal macro workbook is the workbook that gets assigned every time you start Excel. So that makes sense. Every time I start Excel, my ribbon will have the command on it, and that's gonna work fine, because the macro that I want to run, is always available.