Record Macro in Excel is used to perform a task or action in Excel. In this chapter we learn how to record, edit, save and delete macro and its overview. We can easily record a macro. First we need to decide what we want to record. It helps to learn and understand VBA code or macros for beginners. We use VBA to automate repetitive tasks in our regular job. So that we can save time, increase quality in generating reports, speed up the work, reduce errors and many more. In this tutorial you can find step by step instructions to record a macro in Excel.
- Overview on Record Macro in Excel
- Step by Step Instructions to Record a Macro in Excel
- Create Macro Name
- Create Shortcut key for Macro
- Where to Store Macro in & location?
- Create Description for Macro
- Start Recording Macro and Example
- Stop Recording Macro
- Run the Recorded Macro
- Edit the Recorded Macro in VBE
- Macro Security Settings & Enable Macros
- Other Related References
Step by Step Instructions to Record Macro in Excel
Here are the step by step instructions to record a macro in Excel. You can follow these instructions to create a macro in Excel visual basic editor.
- Open Excel
- Click on the Developer Tab from Excel Ribbon.
- Click on Record Macro from the Code group. Now you can see the following Record Macro dialogue box on the screen.
- Here we can specify Macro name, Shortcut key, macro location and description
- Macro Name allows both upper-case and lower-case letters.
- The first character must be a letter.
- name doesn’t include space or special characters.
- It shouldn’t conflict with an existing name
- The macro name maximum length is 255 letters.
- Go to record macro dialogue box.
- After macro name, there is another text-box to enter shortcut key.
- It is combination with Ctrl key.
- after Ctrl key, there is a small textbox. Enter any letter. It shouldn’t match with any existing built-in shortcut key.
- Once shortcut key assigned, you can run respective macro by using this shortcut key.
- Go to record macro dialogue box.
- After shortcut key, there is an option called Store macro in.
- It is a drop-down box with 3 options. Those are This Workbook, Personal Macro Workbook and New Workbook.
- Default value is ‘This Workbook’. You can change this as per your need.
- Go to record macro dialogue box.
- After store macro in, there is an option called Description along with text box.
- In this text box, we can enter description of the macro.
- You can also write macro description using MacroOptions method of application.
- Go to Developer tab from Excel ribbon.
- Click Record Macro button from the Code group.
- Select any cell on the worksheet.
- Apply Fill color to cell from the Home tab.
- Go to Developer tab back and click on the stop recording button to stop.
- Click on Macros from the code group.
- Select recorded macro name and click on edit to see the recorded macro.
- Go to Developer tab from Excel ribbon.
- Click Stop Recording button from the Code group.
- Go to Developer tab from Excel ribbon.
- Click on Macros button from the Code group.
- Now the Macro dialogue box appears on the screen.
- Here you can see list of available macro names
- You can select the macro from the list
- Click on Run button from the right side.
- You can find below screenshot for your reference.
- Go to Developer tab from the Excel ribbon.
- Click on the Macros button from Code group.
- Select macro to edit from the list of macros. li>
- Click on Edit button from the right side.
- Now it shows respective macro in visual basic editor window to edit the macro.
- Here is the below screenshot for your reference.
- Go to Developer tab from the Excel ribbon.
- After recording the macro, close Excel file and reopen it.
- You can see following security warning message.
- Click on enable content to enable macros.
- You can also enable in the following way as well. Click on Macro security from the Code group.
- You can find below screenshot for your reference.
Default if it is not visible in the Excel ribbon, you can add the Developer Tab to the Excel ribbon. For step by step instructions you can click on the following link.
Link: Developer-tab
Screenshot: You can see the Developer tab at Excel ribbon as shown in the following screenshot.
Create Macro Name
Let us know how to create a macro name here. As shown in the above screen there is a text box to specify or define macro name. You can enter macro name in the text box. Default the name will be Macro1,Macro2, Macro3,…
Rules of VBA Macro Name :
Note: If the macro name doesn’t satisfy the above specified rules it appears following message on the screen.
Create Shortcut key for Macro
Here are the steps to create shortcut key for macro.
Where to Store Macro in & location?
Here we see the steps to create shortcut key for macro.
Create Description for Macro
Here we see the steps to create shortcut key for macro.
Example to add description using VBA macro code:
'Add description to Macro Sub VBAF1_Add_Description_To_Macro() Application.MacroOptions Macro:="Macro1", Description:="Write Description Here" End Sub
Start Recording Macro and Example
Let us see the step by step instructions to start recording macro. Let us say we want to apply fill color to cell.
Now the recorded macro looks like below.
Sub Macro4() ' ' Macro4 Macro ' ' Range("BT93").Select With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 65535 .TintAndShade = 0 .PatternTintAndShade = 0 End With End Sub
Stop Recording Macro
Here we see the steps to stop recording macro.
Note: The Stop recording macro button is visible when we are recording macro only.
Run the Recorded Macro
Let us see the steps to run the recorded macro.
Edit the Recorded Macro in VBE
Here are the step by step instructions to test the recorded macro in Visual basic editor window in VBA.
Macro Security Settings & Enable Macros
You can also watch this tutorial in youtube.
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays in Excel Blog
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers
Thanks for providing step by step instructions! Very useful. Looking for more posts… Great content. Easily can understand anyone. All the best!
Thank you!