Automating your actions

Tired of repeating certain actions in Microsoft Excel just to create your perfect spreadsheet? Do you want to speed up the designing process and entering formulas in all your cells at the click of a button? Well, now you can. In Microsoft Excel, you have the opportunity to automate your actions by creating macros.

What are macros?

A macro is the ability to record actions performed in Microsoft Excel and to store those actions in a programming language understood by Microsoft Excel known as Visual Basic.

How do I record a macro?

There are two ways to record a macro. The first way is through the toolbar. It should contain buttons that look like the following:

Or, you can go through the following menu commands:

How do I create a macro?

The simplest way to create a macro is to let Microsoft Excel record a macro for you and you do the work of designing and/or entering formulas into your spreadsheet. Okay. So let's try it. Choose "Record New Macro..." from the Tools menu command. The following window will appear:

Type the macro name "RecordMyFirstMacro" without any spacing in the name. And type the letter "z" in the Shortcut Key field.

Press the OK button when finished. You are now ready to record your actions in a macro. Begin by typing "Women" in cell A1. Press the Tab key. Type the word "Men" in cell B1. Press the Enter key. Click into cell A2 and type "51". Press the Tab key and type "49" in cell B2.

Next, highlight cells A1 to B1. Click the Text Center button.

Select a fill colour for the cells of Gray at 40%.

Highlight cells A2 to B2 and choose a fill colour for the cells of Gray at 25%. Highlight the cells A1 to B2 and put a full border through all the cells.

Stop the macro recording.

You should have a table like the following:

Okay. Lets create a new spreadsheet OR wipe clean the current spreadsheet. Ready? Let us press the key combination Ctrl+Option+z to run the macro we have created. What do we get? An exact replication of the above table including original design and data entered into the exact cells.

What does this look like in the language of Visual Basic?

Want to know the language created by Microsoft Excel to produce this table? Well here it is:

This is basically what a macro does!