How to create a macro in Microsoft Word and Excel

Updated: 02/27/2019 by Computer Hope

Microsoft WordA macro can help improve efficiency when creating documents and spreadsheets, adding or maintaining information, or creating forms for other people to fill out. Microsoft Word and Excel are popular software in which people utilize macros to make data entry and retention easier. Macros in Word and Excel are created using the Visual Basic programming language or by recording actions performed.

To create a macro in Microsoft Word or Microsoft Excel, select from the list below and follow the instruction.

Create a macro in Microsoft Word

To create a macro in Microsoft Word, choose how you want to create it, either manually or by recording actions, and follow the steps provided.

Create macro manually with Visual Basic

  1. In Microsoft Word, click the View tab in the menu bar.
  2. Click the Macros option.

Create macro in Microsoft Word

  1. In the Macros window, type a name for the new macro in the Macro name text field.
  2. Click the Create button.
  3. The Microsoft Visual Basic for Applications program will open, where you can create the macro by typing the Visual Basic code manually.
  4. When you have completed the creation of the macro, click the Save icon in the menu bar and close the Visual Basic program.

Create macro by recording actions

  1. In Microsoft Word, click the View tab in the menu bar.
  2. Click the arrow below the Macros option and select the Record Macro option.

Record macro in Microsoft Word

  1. In the Record Macro window, type a name for the new macro in the Macro name text field.
  2. Click the keyboard icon to assign a key combination to execute the macro.
  3. In the Customize Keyboard window, click in the Press new shortcut key field, then press the combination of keys you want to use for executing the macro in Microsoft Word. For example, you could press the keys Ctrl+Shift+M, and that key combination will be entered into the field automatically.

Assign key combination to execute recorded macro in Word

  1. Click the Assign button in the lower-left corner, then click the Close button.
  2. Recording of the macro will begin immediately after clicking the Close button. Perform the actions you want to record and have the macro execute. You can type text, format the text, create a table, add shapes or pictures, and other actions.
  3. When you completed all the actions you want to include in the macro, on the View tab, click the arrow below the Macros option and select Stop Recording.

Create a macro in Microsoft Excel

To create a macro in Microsoft Excel, choose how you want to create it, either manually or by recording actions, and follow the steps provided.

Create macro manually with Visual Basic

  1. In Microsoft Excel, click the View tab in the menu bar.
  2. Click the Macros option.

Create macro in Microsoft Excel

  1. In the Macros window, type a name for the new macro in the Macro name text field.
  2. Click the Create button.
  3. The Microsoft Visual Basic for Applications program will open, where you can create the macro by typing the Visual Basic code manually.
  4. When you have completed the creation of the macro, click the Save icon in the menu bar and close the Visual Basic program.

Create macro by recording actions

  1. In Microsoft Excel, click the View tab in the menu bar.
  2. Click the arrow below the Macros option and select the Record Macro option.

Record macro in Microsoft Excel

  1. In the Record Macro window, type a name for the new macro in the Macro name text field.
  2. Click the keyboard icon to assign a key combination to execute the macro.
  3. In the Customize Keyboard window, click in the Press new shortcut key field, then press the combination of keys you want to use for executing the macro in Microsoft Excel. For example, you could press the keys Ctrl+Shift+M, and that key combination will be entered into the field automatically.

Assign key combination to execute recorded macro in Excel

  1. Click the Assign button in the lower-left corner, then click the Close button.
  2. Recording of the macro will begin immediately after clicking the Close button. Perform the actions you want to record and have the macro execute. You can enter data, format the data, create a chart or graph from the data, add formulas, and other actions.
  3. When you completed all the actions you want to include in the macro, on the View tab, click the arrow below the Macros option and select Stop Recording.