Hi. In this Excel tutorial, we’re going to go over how to edit a macro in Excel and, in doing so, we’ll do a brief overview of how the VBA editor
is laid out. If you’d first like to see how to create a macro, please do take a moment to watch our tutorial on that.
So, the macro we’re editing is one that takes this little bit of data that's on the screen and makes it looks more presentable.
Like this, but we need to revise it. We need to change the report name from “Sales Report” to
“Weekly Associate Sales.” We can easily do that in the VBA Editor.
And, by the way, if you enjoy this tutorial, don’t forget to Like the video and subscribe to the channel for even more tips. The VBA editor is
the tool that Excel uses for macros. You can access it from the Developer tab and click Macros.
Here, we see a list of our available macros. Select the one that you need, in this case Report Cleanup, and Step Into. Now, you
could also choose Edit, but if your macro is stored in your hidden Personal workbook, like mine is, and you choose Edit, then you'll need
to first uhide and open that workbook. So, you have a few more steps to do that way. So, we'll click Step Into.
You should now be in the macro you selected. You can tell this because the name of the macro we selected is highlighted here in
yellow. Let's go over some of what we see on our screen. It'll be good to have a basic understanding of what some of these items
are. So, on the left, here, you see that we have 2 VBA Projects - Macro Edit Example and Personal. A Project is just another name for a
workbook. The Macro Edit Example is the workbook with the data that we want to format.
The Personal workbook is where all my macros are stored – this is a hidden workbook auto created by Excel just for macros.
So, beneath each of these, you see different things.
Beneath the Macro Edit Example, you see each sheet in the workbook. And, then, beneath the Personal macro,
you see Modules. So, in my Personal macro workbook, a module was created for each macro that I've ever created and even after
deleting a macro the module stays - even if it is empty. So, the macro we're editing is here in Module 9. So, our macro is a sub
procedure. Not real important to know what that is for this example, but that's what this Sub, here,
stands for. And your macro is located between the Sub, up here with the name,
and, if you scroll to the bottom, down here where it says End Sub. And, in between those 2 lines, we can add more VBA code, delete
code or change the existing code. In this example, all we want to do is revise the report name. So, there's a lot of code here. So, with
my cursor in the part of the screen where the code is, I'm just going to use Ctrl+F to search for "sales report."
And, by the way, if this macro is one that you cannot easily rerecord or it will be catastrophic should it become ruined, it's a good idea
to copy it. You can just select everything and use Ctrl+C to copy and then paste it and save it elsewhere - a Word document, even.
And, this way, should you have a macro emergency, you can just paste it back in.
To confirm that we're in the right place, there are a couple of things that we can look at. First, sales reports is in quotation marks and
doesn't have an equal sign. This let's us know that it's a text entry and, then, if you look above it, the
cell, B2, is the one that contains the report name that we want to revise.
Once we’re certain that we’re in the right place, we simply highlight the report name and we type in the new name that we want for our
report. And then click Save. And we can close the VBA editor. Click OK. And now, when we rerun the macro,
it will update with the new report name. So, I hope you enjoyed this tutorial on how to change a macro in Microsoft Excel. If you did,
please make sure to Like the video and don’t forget to subscribe to this channel. Thanks!