Step 1 - Start with the macro recorder

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.

  1. First create a table in Word.

    Create Table

  2. Place your cursor in the first cell of the table. In the example above, we’ll place the cursor on the cell Andrew.

  3. Click Tools > Macro > Record New Macro

  4. Change the macro name to DeleteRow, and click OK.

Tip: The macro name can’t contain spaces or special characters.

  Record Macro

  1. Now with the recorder started, select the Table Layouttab, and click Delete > Delete Rows.

    Delete Row

  2. 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.

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.