SECTION 3
Lesson 3.1: Creating Macros in Excel

   

 

 

Perhaps the most convenient way to run a macro is to simply click a button on a toolbar. In Excel 2003, you can assign a button to macro, and locate it conveniently on the toolbar of your choice.

 

To assign a button to your macro, first make sure the toolbar you want to put your button on is visible. You can do this by choosing View->toolbars and putting a check mark by the toolbar of your choice.

 

To select a button for your macro, choose View->Toolbars->Customize from the menu bar. This will display the Customize dialogue box.

 

 

In the customise dialogue box, click the Commands tab, and scroll down to the word Macros. Select Macros and you will see a smiley face icon with the words Custom Button in the area on the right under the Commands label.

 

Click on the custom button icon and hold your left mouse button. You can now drag the button to a location on a toolbar of your choice.

 

When you are dragging, your mouse pointer will turn into an arrow with a small shaded button under its tip, and a small box with an x in it. As you move the mouse pointer, the x will turn into a + when you are at a location that can hold the button. When you have found a convenient spot for your macro button on a particular toolbar, release the left mouse button and the smile face icon will appear on the toolbar.

 

Here is the standard toolbar before the macro button has been added.

 

 

Here is the standard toolbar after the macro button has been added.

 

  

You can change the location of the button, or remove it by dragging it back to the customize dialogue box, as long as the Customize dialogue box is visible on the screen.

 

To assign a macro to the button, close the Customize dialogue box, and left click on the macro button to make the Assign Macro dialogue box appear.

 

 

Select the name of the macro you want to associate with the button, and click OK. The selected macro will now be assigned to the button.

 

The macro button should now be available whenever you open a workbook. However, depending on the macro security level, you may get a security alert or prompt when you click the macro button. If macro security is set to high, you may not be able to use the macro associated with the button. Excel allows you to set a level of security for macros, because macros from unknown sources could potentially perform malicious actions.

 

 Depending on the level of macro security, you may be refused from using the macro, or you may be asked whether or not you will permit macros to run.

 

 

If, when you assign a macro to your button, you choose a macro that is stored in the personal macro workbook, the macro should be available to all your workbooks without any security alerts or prompts regardless of the security level.

 

The macro security options are available under Tools->Macro->Security. Be cautious when changing security levels and remember, macros can contain viruses and have the potential to perform malicious actions. You should only run macros from authenticated trusted sources.