The main purpose of recording a macro is to automate a repetitive task, which will save you a lot of time. For example, you need to format some dates by repeating the same steps. If you have a similar tast, you can record a macro and then play the macro as many times as you want.
A macro basically is a recorded sequence of commands and actions, and it includes all the steps you work with the worksheets, such as typing a number, clicking a command in the ribbon, formatting a data range, entering a formula, and many other activities.
Please note that if you have made mistakes while recording a macro, the errors will be part of the macro and will repeat when you play the macro again. To avoid potential errors, one suggestion is to practice more and re-record your macro with the correct steps.
The following is one simple example of recording a macro and how to play the macro.
Part I: Record a Macro
Step 1: In the "Developer" Tab from the Ribbon, click the "Record Macro";
Step 2: In the new window, type the Macro name, and fill the other three sections (optional).
- Please note that the first character of the macro name must be a letter. You can use the underscore, but the space is not allowed in the macro name.
- The shortcut key section and the description section are optional.
Step 3: Click "OK" to save the macro. In the worksheet, you can enter the data in the cells. When you complete the data entry, please click "Stop Recording" in the "Developer" tab.
Part II: Play a Macro
Step 1: After you complete and save a macro, you can play the macro when you need it. To play a macro, you need to click the "Macro" command;
Step 2: In the new window, select the macro name, and click "Run";
Step 3: The numbers you entered will appear.
After you record your macros, you can use the Visual Basic Application (VBA) to improve or edit the macro for other purposes.