The easiest way to start programming with VBA in Office for Mac 2011 is to use the Macro Recorder. The recorder simply records a task that you perform in your Office app, and then converts it into VBA code. Later, you can look at the code that was generated to learn what VBA code is used to complete that action.
You may be wondering, why do I need to learn the code, if the recorder can do the work for me? As you use the Macro Recorder to create macros, you may find that there are limits to what you’re able to record, and you’ll need to go into the code to create more complex capabilities in your macro.
Let’s look at an example of how to record the task of deleting a row from a table in Word.
First create a table in Word.
Place your cursor in the first cell of the table. In the example above, we’ll place the cursor on the cell Andrew.
Click Tools > Macro > Record New Macro
Change the macro name to DeleteRow, and click OK.
Tip: The macro name can’t contain spaces or special characters.
Now with the recorder started, select the Table Layouttab, and click Delete > Delete Rows.
Stop the Macro Recorder by clicking Tools > Macro > Stop Recording.
Now that you’ve recorded your action, let’s take a look at the code.
Note: The Macro Recorder does not record keystroke.