What are “Macros”?

“Macros” are basically small programs that we use to carry out repetitive tasks automatically.

A “Macro” stores all the actions we perform on our keyboard as a “Visual Basic” program.

Later, when we want to run a “Macro”, we only need to click one button to perform the series of actions that we had previously recorded.

Suppose, we want have our name, company name, address, phone, fax in the upper left part of every sheet of our “Workbook”.
When we include all these actions in a “Macro”, we need not repeat all this, but only use a single button to automatically repeat these actions as many times as we wish.

“Macro” Recording

In order to record “Macros” we choose “Tools” from the menu bar, select “Macro” and select “Record New Macro …” .
This opens the “Record Macro …” dialog box.

Enter a name for your “Macro”. You may not use spaces.
Next we select “Store macro in …” in the dropdown menu to specify where we want to save our “Macro”. By default this is “ThisWorkbook”.
In the box we can assign a Ctrl “Shortcut” key (“Shortcut”) for our “Macro”, but if you do this make sure it will not overwrite any existing “Shortcut”.
eg CTRL P already exists for the “print” command.

Click OK, to record. your “Macro”.

From then on, all your keystrokes will be recorded.

When you make a mistake, click the “Stop Recording” button   in the “Macro” toolbar, delete the “Macro” and start again.

The “Macro” toolbar appears whenever a “Macro” is recording.

We use this toolbar to stop recording our “Macro” and set the cell reference.

We click on the button on the right in the “Macro” toolbar when we want a “Relative cell reference”.

The default, when recording a “Macro”, is “Absolute cell reference”.

When you record in an “Absolute cell reference”, the macro will always start in the cell where you started recording.

So if you want in “Relative cell reference”, first click on this cell for all your other operations.

When you have completed all your actions, click the “Stop Recording” button.

We can now run the “Macro” when we want.

Execute “Macros”

To run a recorded “Macro”, we click on “Tools” from the menu bar, select “Macro” and click “Macros …”
In the dialog that appears, we see all our “Macros” that we have previously recorded.

Select the macro and click “Run”.

A note for 2003 and XP users:

When “Macros” from previous versions can not be executed, you need to set the security settings from “High” to “Medium”.

To do this we choose “Tools” from the menu bar and select “Options “.

We choose the “Security” tab and click “Macro Security” button.

In the tab “Security Level” we choose “Medium”.

Remove “Macros”

To remove “Macros” we choose “Tools” from the menu bar, select ” Macro” and click ” Macros …”
Select the “Macro”, and click the “Delete” button on the right side of the dialog.

A “Personal Macro Workbook “

When we create “Macros”, they are included in the workbook in which we created the “Macros”. When we open other “Workbooks”, we can also use the “Macros” created in these.

But, once we have closed the “Workbook” where the “Macros” are created, we can not use it in another “Workbook”.

To solve this problem we choose “Personal Macro Workbook” from the dropdown menu in the “Record Macro ” dialog box when we record a “Macro”.

The “Personal Macro Workbook” is a hidden “Workbook”, although still open, we can not see.

However, we can save several “Macros” to use in all “Workbooks”.

When you quit, Excel will ask you if you want to save the “Macro” in the “Personal Macro Workbook” of “Macros”.

Once we have “Macros” stored in the “Personal Macro Workbook” we need to make this “Visible” in the “Workbook” to edit or delete them.

Click on “Window” the menu bar and select “Unhide”.

Select the “Workbook” named as “Personal.xls” and click OK.

We can then remove or edit any “Macro” from this “Workbook”.

When you’re done, click “Window” from the menu bar, select “Hide” and choose “Personal.xls” and click OK.

Do not forget to “Hide” to prevent them from being removed or changed when you do not want.

Awesome!
You've completed Lesson 31
START NEXT LESSON