5. Editing and Deleting Macros

Subtitles Enabled

Sign up for a free trial to continue watching this lesson.

Free trial


Editing and deleting Macros can be tricky, particularly if you save a Macro to the Personal.xlsb file. In this lesson, I'll show you how to accomplish these tasks.

Lesson Notes

Editing Macros

- To edit a Macro's keyboard shortcut or description, go to 'Options' in the Macro dialogue box
- To change the Macro code itself, you'll need to open the Visual Basic Editor
- Macros are found in the 'Module files' in the VBA project window

Deleting Macros

- Press 'Delete' in the Macros dialogue box to remove the selected Macro
- However, if the Macro is stored in Personal.xlsb, the process is more difficult
1 Open up the VBA editor and find the Module where the Macro exists
2 Then delete all of the code

Keyboard shortcuts

ALT + L , P, M: Open Macro dialogue box
ALT + F11: Open Visual Basic Editor
ALT + Q: Close Visual Basic Editor


We'll often record a macro and then realize that you've made an error and you want to edit or delete this macro. If you've saved the macro to the workbook this process is quite straight forward. In this example, I have a macro called Highlighter saved in the workbook. And this macro simply changes the background color of the cell to yellow by pressing Ctrl + Shift + H. Let's say that I now want to edit this macro. Let's go to the Developer tab with Alt + L, and then P, M, to open the macros dialogue box. And here I can find my macro name. If I'd like to change the keyboard shortcut or the description, I can go to the Options button. So I'll press this, and change the shortcut key to say, Ctrl + Shift + B. If I'd like to change the code itself, we need to go to the Edit button. And this opens the Visual Basic editor and I can see all of the code written for this particular macro. In the project window, I have a VBA project with the name of my Excel sheet included. Within the VBA project I have Microsoft Excel objects and modules. And in this file, Module 1 is where my macros are stored. To delete the macro, I'll exit out of the Visual Basic editor with Alt + Q, I'll open up the macros menu again with Alt + L, P, M and then I'll simply press the Delete button. And this removes the macro. If I open up the Visual Editor again with Alt + F11, and go to my Module 1 as before, I'll see that the code is missing. So deleting a macro simply removes the code from Module 1. This is important to remember, for when we delete macros stored in the Personal.XLSB file. Let's return to the macros window by pressing Alt + Q. And this time I am going to create another macro off-camera called createBorder which will be stored in the XLSB file. Let's open up the macros dialogue box with Alt + L and then P, M where we find our createBorder macro. If I try to delete this using this button in the dialogue box, I'll get an error, because it tells me I can't edit a macro on a hidden workbook. So instead we'll need to go the VBA code. So I'll hit Exit and then Alt + F11 to open up the Visual Basic Editor. We now need to go to the modules within the Personal.XLSB file and I should find my macro in here. Let's now select all of the code and delete. Then I'll exit by pressing Alt + Q. And if I now go back to my macros list I'll find that the macro has been deleted, exactly what I want.

Deleting and Editing macros can be a bit tricky at the start and you may need to re-watch this video a couple of times to understand how I've completed this task, however if you can remember that macros are just blocks of code stored in the modules of the desired file then you should find it quite easy to edit and delete these objects.