In this post, we will see where our macro is saved.

Excel VBA — Where is my macro | Intro­duc­tion to macros and VBA 04

Let’s go to the Devel­op­er tab. On the left, we can see the Visu­al Basic com­mand. We can also press the Alt + 11 short­cut. So, let’s click it. Now, in the worst case sce­nario, all we would see is a grey win­dow. In this case we need some more infor­ma­tion. Let’s turn on a small­er win­dow by open­ing the View menu, and select the Project Explor­er com­mand (Fig. 1)

Fig. 1 Project Explor­er command

What we should see here is all Excel files that are opened, as well as our PERSONAL.XLSB files, which are our per­son­al files for macros (Fig. 2)

Fig. 2 Files

In each file, we should also see some work­sheets and sim­i­lar things, espe­cial­ly mod­ules. Our code should be writ­ten as Mod­ule 1 by default. Before we click on it, let’s go to the View tab one more time and click on the Prop­er­ties Win­dow com­mand (Fig. 3)

Fig. 3 Prop­er­ties Window

This win­dow shows us infor­ma­tion about files or work­sheets (Fig. 4)

Fig. 4 Work­sheet information

Let’s go now to Mod­ule 1. After dou­ble-click­ing on it, we should have a small win­dow opened. Our first macro was very sim­ple, how­ev­er we have more rows than we need. We don’t need the Option Explic­it line, so let’s delete it. Next, we have the Sub key word which starts our macro and the phrase End Sub which stops it. Only the ele­ments that are between those two lines cre­ate our macro. Our macro is called TODAY. The oth­er time I men­tioned that the TODAY func­tion is a DZIŚ func­tion in Pol­ish, how­ev­er no mat­ter what ver­sion I have on my com­put­er, VBA is Amer­i­can and will use Amer­i­can names and pro­ce­dures in macros. When we look at our macro, we can see the line with the TODAY func­tion, as well as a few green lines start­ing with green sin­gle quo­ta­tion marks. They are just com­ments. In VBA, com­ments start with a sin­gle quo­ta­tion mark, and are not part of the VBA code (Fig. 5)

Fig. 5 VBA code with comments

Hav­ing the above in mind, I can just delete them and leave only the line that is an actu­al VBA code. Now, it’s quite sim­ple when you read it. ‘Selec­tion’ means that we just select­ed some­thing, a dot means the next step after select­ing. Then, we have the For­mu­la, which means that we put a for­mu­la. The R1C1 isn’t impor­tant for us. Then, our for­mu­la equals the TODAY func­tion. That is the whole VBA code (Fig. 6)

This image has an empty alt attribute; its file name is fig.-6-1024x293.png
Fig. 6 An actu­al VBA code

https://www.youtube.com/watch?v=Idag9QNODuY