Copy part of a macro to create another macro
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.
- Under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros.
- Open the workbook that contains the macro that you want to copy.
- On the Developer tab, in the Code group, click Macros.
- In the Macro name box, click the name of the macro that you want to copy.
- Click Edit.
- In the code window of the Visual Basic Editor, select the lines of the macro that you want to copy.
Tip To copy the whole macro, include the Sub and End Sub lines in the selection.
- On the Edit menu, click Copy.
Tip You can also right-click and then click Copy, or you can press CTRL+C.
- In the Procedure box of the code window, click the module where you want to place the code.
- On the Edit menu, click Paste.
Tip You can also right-click and then click Paste, or you can press CTRL+V.
Tip You cannot edit your Personal Macro Workbook file (Personal.xlsb) because it is a hidden workbook that is always open. You must first unhide it by using the Unhide command. You can also open it in the Visual Basic Editor by pressing ALT+F11.
No comments:
Post a Comment