Run A Macro

Excel allows you to run macros in a worksheet that exists either in the current workbook or in any other Excel workbook. However, you can only run a macro from any other workbook as long as you have the corresponding workbook open within Excel. When you run a macro, Excel re-creates the recorded steps that you performed to create it, or it runs the VBA code that you created in the Visual Basic Editor. See the section "Record a Macro" to learn how to record a macro and Chapter 3 for more information on the Visual Basic Editor.

You select macros to run from the Macro dialog box, which lists all currently available macros. Available simply means that Excel can locate the macro in an open workbook. Because Excel only knows about macros in open workbooks, you must open the workbook containing the macro you want to run.

When you create a macro, Excel stores it in one of three locations, the current workbook, a new workbook, or the Personal Macro Workbook. Excel opens the Personal Macro Workbook as a hidden file each time you run Excel, and makes all macros you store there available to run with any workbook. If you store a macro in a separate workbook, you must open the workbook containing the macro in Excel. You can learn more about creating a macro in the section "Record a Macro."

To run a macro from another workbook, you must have a macro from a signed source, or you must set your macro security to either Medium or Low. The default macro security level, High, requires that all macros from other sources be signed. Setting your macro security to Medium or Low lets you run unsigned macros. See section "Set Macro Security" for more information about macro security.

RUN A MACRO

Ln Click File O Open.

RUN A MACRO

Ln Click File O Open.

■ The Open dialog box displays.

0 Click the workbook containing the macro you want to run.

■ The Open dialog box displays.

0 Click the workbook containing the macro you want to run.

ffiXJ Ht You can use the Macros In field to limit the number of macros that display on the Macro dialog box. To see the macros in any open workbook, including the Personal Macro Workbook, you can click the E] and click the All Open Workbooks option. If you only want to see macros from a specific workbook, select the name of the desired workbook in the Macros In drop-down list. For the global macros stored in the Personal Macro Workbook, you need to select the PERSONAL.XLS option.

Excel differentiates between macros listed in the Macro dialog box by placing the name of the workbook that contains the macro in front of the macro name. For example, Excel lists a macro named Sum_Expenses in the Personal Macro Workbook as PERSONAL.XLS!Sum_Expenses. Because of this nomenclature, two workbooks can have macros with the same name. In other words, if the macro Sum_Cells exists in both the Budget.xls and Expenses.xls workbooks Excel treats them as two different macros because they are stored in two different locations. The Macro dialog box lists the macros as Budget.xls!Sum_Cells and Expenses.xls!Sum_Cells.

Realidades Capitulo Answers

■ The selected workbook opens.

■ The selected workbook opens.

—0 Click the cell where you want the macro to execute.

■ The Macro dialog box displays a list of available macros.

-■ If the macro is not listed, you can click here and click the location of the macro.

Click the macro you want to run.

■ The selected macro executes and makes the appropriate changes to the worksheet.

■ To run the macro again, repeat steps 3 through 6.

0 0

Post a comment