Deleting macros from within a macro in Excel is a relatively simple process. To do so, simply follow these steps:
(Optional): If you want your macro to be available in all workbooks, you can save it in your Personal Macro Workbook (PMW). To do so, simply click on the File menu and select Save Personal Macro Workbook.... This will open the Save As dialog box. In the Save As dialog box, make sure that you save your file with a .xlsm
extension (e.g., "My Macros.xlsm"
) and click Save & Close. Your macro will now be saved in your PMW and will be available in all workbooks.
(Note: If you want your macro to be available only in the current workbook, you can skip this step.)
(Optional): If you want to give your macro a shortcut key, you can do so by clicking on the Macro Options... button in the VBE toolbar. This will open the Macro Options dialog box.
In the Macro Options dialog box, enter the shortcut key you want to use for your macro in the Shortcut key text box.
(Note: You can use any combination of Shift, Ctrl, and Alt keys as well as a letter or number key.
For example, if you wanted to use Ctrl+Shift+M as your shortcut key, you would enter that combination in the Shortcut key text box.
If you wanted to use just M as your shortcut key, you would enter M in the Shortcut key text box.
If you wanted to use Shift+M as your shortcut key, you would enter +M in the Shortcut key text box.)
Once you have entered your shortcut key combination, click "OK" strong >to close the Macro Options dialog box.
(Note: If you do not want to use a shortcut key for your macro, you can skip this step.)