Excel 2016 Macros
Excel 2016
Lesson 3 – Editing Macros
C OPYING M ACRO C OMMANDS D ISCUSSION
There may be times when you want to combine macros to operate them more efficiently. For example, if three different macros open three separate workbooks, you can combine the three macros to open all three workbooks in one step. You can combine macros by copying and pasting the command statements from one macro to another. Macro commands can be copied from other macros, other modules, or even other workbooks.
Copying macro commands saves the time it takes to write or re-record a macro, or insert new macro steps.
NOTE If an error occurs while running a macro, the Microsoft Visual Basic dialog box opens. You can select the End button to stop running the macro. If you select the Debug button, the Visual Basic Editor opens with the command that created the error highlighted. You can fix the error and click the Continue button on the Standard toolbar to continue the macro, or you can click the Reset button on the Standard toolbar to stop debugging the macro.
P ROCEDURES
1. Open a workbook containing macros and enable the macros. 2. Display the Developer tab on the Ribbon .
3. Select in the Code group to open the Visual Basic Editor. 4. Display the module containing the macro text you want to copy. 5. Select the macro text you want to copy. 6. Click the Copy button on the Visual Basic Editor Standard toolbar. 7. Position the insertion point where you want to paste the macro text. 8. Click the Paste button on the Visual Basic Editor Standard toolbar.
S TEP - BY -S TEP Copy macro commands between modules.
If necessary, enable the macros. Open the Visual Basic Editor using the Visual Basic button in the Code group on the Developer tab. Then, open the CITY57.XLSM - Module1 Code window using the Project Explorer task pane and display the NewYork macro.
OFFICEPRO, Inc.
Page 47
Made with FlippingBook - professional solution for displaying marketing and sales documents online