How to Record Macros in Excel

  • Post author:
  • Post category:Uncategorized

A Macro is a code written in Visual Basic for Applications (VBA). We use Macros to record steps taken in carrying out tasks so we can quickly carry out those steps in the future with only a few clicks.

When we record a macro, Excel will carefully follow the steps and take note of each thing we do in the form of codes. When we stop recording and then save the macro, we can use it in future to regenerate those exact steps we took. In this tutorial, we will learn how to record a macro in Excel.

Figure 1 – How to record VBA (macros)

Activate the Developer Tab to Record Macro

If we cannot find the Developer Tab in the Ribbon at the Top of our Excel Worksheet, then we must activate it.

  • We will right-click anywhere on the tabs in the ribbon and click “Customize the Ribbon” option.

Figure 2 – Activate to record macros in excel

  • This will open the Excel Options Dialog Window. We will click on Customize Ribbons
  • In the Choose Commands from the text box, we will click the drop-down menu and select All Tabs.

Figure 3 – Recording in Excel

  • In the box below choose commands text box, we will scroll down to find the Developer Tab
  • When we find it, we will click on Developer Tab and then click on Add and select OK

Figure 4 – Activate the Developer Tab to use the Excel Macro Recorder

Recording Macros (VBAs) in Excel

  • In our Excel Worksheet, we will go to the Developer Tab and select “Record Macro” in the Code group

Figure 5 – how to record vba

  • Alternatively, we can go to the View Tab and click on Macros to select “Record Macro” from the drop-down list

Figure 6 – How to record a macro in excel

  • Record Macro dialog box will pop up. Here we will;
    • Enter the Macro name we will use in identifying our Macro. We may not use spaces between words
    • Next, we will enter a Shortcut key. Whenever we want to run a macro, we will be able to do so using this shortcut key
    • We will choose where to store the macro. By default, we can select “This Workbook.”
    • We will enter a Description about the Macro, so other users can easily understand the purpose of the macro.
    • We will click OK

Figure 7 – VBA Record

  • After we click OKEVERY STEP and KEYSTROKE will be recorded.
  • In this example, we will use the macro recorder to record a macro that will type in specific numbers; 555, 666,777,345,324 into the Range A1:A5 and then use the Auto Sum feature to get their sum.

Figure 8 – How to use a macro recorder in excel

  • To stop recording, we can go to the View Tab and click on Macro to view the dropdown list, where we will select Stop Recording

Figure 9 – Stop recording macro

  • We can also go to the Developer Tab and select Stop Recording in the Code Group

Figure 10 – Recording in Excel

  • Alternatively, we can find a small square box at the bottom left of the worksheet. If we click on this square box, Macro will stop recording.

Figure 11 – VBA Record

Explanation

When we record macro, a unique set of code will appear in the Visual Basic window.  When we finish recording the macro, we can quickly click on View Macro. Next, we will select Edit to see the code generated.

Figure 12 – How to record a macro in excel

However, it’s crucial that before recording macros, we must be sure of each step we take. Excel records every little step and does not erase any mistakes made. Therefore, if we take a wrong step while recording the macro, we cannot change it.