Macro Recorder


Excel has a feature called Macro Recorder. This tool tracks the actions performed in the spreadsheets and transforms them into VBA code. It's a great way to understand how things work.

Access the Macro Recorder feature in the Developer tab $\rightarrow$ Record Macro.

Record Macro

Recording a Macro

For learning purposes, it is recommended that you place the Excel and VBE worksheet windows side-by-side when using the Macro Recorder feature. In this way, you can follow every step of the code creation.

Excel VBE

Try to record a macro now!

  1. Click on the Developer tab
  2. Click Record Macro
  3. Name the macro Shortcut Key and Description are optional
  4. Perform actions in Excel For example, fill in a value in a cell
  5. At the end, click on the Stop Recording button (in the same location as Record Macro)

Note that when using the Macro Recorder feature, a module is automatically created in the VBE Project Explorer.

Recording Macro

Avoid unnecessary errors and actions while recording a macro because everything is being recorded and encoded.

Stay alert and do not be alarmed because the Macro Recorder feature generates a lot of unnecessary code.

The Macro Recorder feature can also be accessed quickly by the shortcut located in the lower left corner of Excel.

Recorder Shortcut

Viewing Saved Macros

One way to access recorded macros is through the Macro Window.

The are a few ways to open the Macro window:

  1. On the Developer tab, clicking in Macros
  2. On the View tab, clicking in Macros
  3. Through the shortcut Alt+F8
View Macros

One way to access the code created by the recorder is by clicking Edit.


Relative References

If the Use Relative References option is turned off at the time the macro is being written, when you run the macro it will perform ("literally") the same actions in the same cells.

Usually the aim of creating and writing macros is to generate a code that can be used in a wide, relative way. Therefore, it is advisable to leave this option enabled.

Use Relative References

Saving Your Work with Macros

If you created a macro and when saving your work the warning below pops-up:

Wrong File Type

Click "No", so you do not lose the macro you created.

Whenever you create macros in an Excel file be sure to save it in a macro-enabled extension (.xlsm ), otherwise all created code will be lost.

  1. Click File
  2. Go to Save As
  3. Select the extension (.xlsm )
Saving *.xlsm


SuperExcelVBA.com is learning website. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. All Rights Reserved.

Excel ® is a registered trademark of the Microsoft Corporation.

© 2024 SuperExcelVBA | ABOUT

Protected by Copyscape