To run a macro, click the Developer tab in the ribbon and then click the Macros button. Then in the Macro dialog box, click the button next to Macros inand select the location of the macro you're trying to run. Click a macro and then click Run. You can also activate the Macros button after clicking the View tab in the ribbon.
- [Voiceover] In this workbook called Playback Ribbon we've got a worksheet called Budget 2017, and the numbers are large and we've previously written a macro that displays numbers in millions with a single decimal, and let's say we haven't used that macro in a long time, we think it's got a keystroke shortcut but we're not sure, let's see if it's available in this workbook. How do we know, and how do we run a macro if we forgot that it has a keystroke shortcut? Or maybe it doesn't have one, we're not always sure. So, we can go to the Developer tab in the ribbon or the View tab, either location.
Let's start with the View tab first of all. Far right button, you can either click the button itself, if you click the arrow below it, you want to choose View Macros, or if you simply click the icon you end up in the same place, the macro dialog box. Here's the macro in question, values in millions. If we are curious right now if there is a keystroke shortcut, we think there is we're not sure maybe, we'll click Options and see if it has been applied or possibly that's blank.
But otherwise what do we see? The word Run. Only playback what a macro does we can use the word Run or Playback or Execute, they all mean the same thing. Let's make this macro do what it has to do. Now, right now in this worksheet, what have I highlighted? I wasn't thinking properly perhaps so what do we begin with here? I certainly didn't want to make just that cell have that display, so maybe we'll highlight the entire worksheet, the numerical part of it at least, or maybe we'll just test this out. Sometimes you'll highlight just the relevant cells that you care about for the moment.
How 'bout those? Let's display all these in millions. We can also do this by way of the Developer tab, off to the left we'll see the Macros button, there it is, highlight the macro in question, values in millions, let's click Run. There it is. You might say that's our fallback method for running a macro, maybe we didn't know if there was a keystroke shortcut or we forgot it, if a macro is present we can get to it that way. Now a bit later you will see that certain macros are going to be available for all workbooks, but the same technique is going to be used when we go to Developer or the View tab and we choose Macros, we can view macros not only in this workbook, sometimes you'll see that prompt there, this workbook, but all open workbooks.
And we might have different workbooks open and a bit later you learn about a workbook called Personal Macro Workbook where we'll store macros that might be used in any different workbook. So, we can always get to macros by way of the Developer or View tab, even if we've got the keystroke shortcut. Not always the fastest way, but it's our fallback method of activating a macro.
- Understanding macros security
- Running macros
- Using Visual Basic for Applications (VBA) to program macros
- Recording macros
- Expanding macros with the if statement
- Using For…Next, Do While, and Do Until statements to repeat action
- Joining two macros
- Streamlining macros