Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Excel macros let you perform complicated tasks such as manipulating PivotTables quickly by recording the steps and playing them back when needed. In this movie, I will show you several ways run your macros so you can pick the one that works best for you. I have started with just a blank workbook open and the reason for that is that I want to show you what can happen if you open a workbook that contains a macro. To do that, I will trust Ctrl+O to display the Open dialog box and then I will navigate to my Exercise Files folder, which is on my Desktop, and then under Chapter 8, I will double-click Running, which is the sample file we will use for this movie.
When I double-click the file to open it, you might see a security warning bar, indicating that macros have been disabled. You then have two options: either to enable the content or to click the Close button to close the message bar without enabling macros. In this example I do want to use the macros so in a moment we'll click of the Enable Content button. But before that, if you don't see this bar I want to tell you how you can enable macros from within the Trust Center dialog box, because what probably happened, if you didn't see the security warning bar come up, it means that macros have been turned off entirely for this installation of Microsoft Excel and if that's the case and you want to run macros here's what you do.
You click the File tab to go to the Backstage View and then click Options. Then in the Excel Options dialog box, click Trust Center and then click Trust Center Settings. In the Trust Center dialog box, click Macro Settings and here you can select what you want to do with your macros. At present I have my Macro Security Setting at Disable all macros with notification. As we saw earlier that gives me the option to allow macros to run.
If you didn't see the security warning bar and you're having trouble running macros, then your macro's security might be set to Disable all macros without notification or Disable all macros except digitally signed macros. So if you didn't see a message bar then you need to come into this dialog box and set your Security to Disable all macros with notification. If you're in a corporate or enterprise environment then please make sure that making that change is okay with your IT department. Let them know that you are working through this course and the workbook contains macros and is known to contain macros.
If they're okay with it or if they will do it for you, go ahead and change your Macro security setting. So I have mine where I need it so I will click Cancel twice to close out of the Excel Options dialog box and I can click the Enable Content button to enable macros. Now there are several ways to run a macro in Microsoft Excel. The first is from within the Macros dialog box. To view the Macros dialog box click the View tab and then at the far right end you'll see the Macros button.
Click the down arrow and then click View Macros. When you do, you see the macros that are available inside of your workbook. If you want to run a macro then just click the name and then click Run. The macro that I just created rearranged the contents of this PivotTable. Another way to run a macro is to assign it to a shape. So let me go to the Insert tab, click Shapes, and then I'll just create a rounded rectangle and I will make a small button here and then I'll type some text to put in the middle, "Macro launch", and then right-click the Shape and click Assign Macro.
This displays the Assign Macro dialog box and you can select any of the macros that you want. In this case I want to do Company by Quarter and Year and then click OK. Now if I click away from the button to release the selection and move my mouse pointer over the button, you'll see that the mouse pointer changes to a pointing hand. It's the same pointing hand you might see if you hover your mouse pointer over a hyperlink such as one that leads to a webpage. That's because clicking this button or a hyperlink will lead to an action.
So the pointing hand means that something is about to happen, whether it's going to another webpage or running a macro. In this case if I click the button, Excel runs the macro that I assigned to it. Now the final way that I'm going to show you to run a macro is by creating a button for it on the Quick Access Toolbar. To do that click the Customize Quick Access down arrow, then click More Commands. Then on the Quick Access Toolbar page of the Excel Options dialog box in the Choose Commands From list, click its down arrow and then click Macros.
Doing so will list the macros that are available to you in this workbook. In this case I want to do Year_Month_Company. So I will click it and click Add and then after you add the button you can change its appearance. Make sure that the macro is selected over on the Quick Access Toolbar side of the pane, click Modify, and then select the button that you want. In this case I will apply a Play button. Everything looks good and I will leave the display name the same and click OK.
Now when I click OK, Excel adds the button to the Quick Access Toolbar. When I click it, Excel runs the macro. If you run a macro occasionally or you don't want your colleagues running it out of curiosity, you might find the best solution for your application is to run the macro from the Macro dialog box. If you build a worksheet that relies on a macro to update the values or to write values in other worksheet, then attaching the macro to a shape might be best. If you run several macros frequently, then adding them to the Quick Access Toolbar makes them available without cluttering your display.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 82559 Viewers
80 Video lessons · 133822 Viewers
52 Video lessons · 67108 Viewers
59 Video lessons · 52936 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.