In this post, you’ll learn about Macros, its use case and how to use Macros in your Excel workbook.
What is an Excel Macro?
Excel Macro is a record and playback tool that records your Excel steps and you can playback it as many times. VBA (Visual Basic Applications) Macros saves time. Macros is a programming code that runs in an Excel environment.
Uses of Macros
- Macros automate repetitive tasks
- You can use a macro to record the steps of importing the data, formatting it to meet your business reporting requirements.
- Macros record your steps in excel so you can play it at any time and for countless times.
- Let’s see an example of a Macro program in Excel.
How to Enable Developer Option in Excel?
To run a macro program, you need to have access to developer option in Excel.
To enable the Developer option,
- In the main menu “FILE”
- Select “Options.”
- In the corresponding window, Click on Customize Ribbon
- Check the Developer option
- Click on OK button
Now, you can see the Developer tab in the ribbon.
Sample program using the macros in Excel
To run a macros code in Excel, follow these steps.
- Go to Developer options in the ribbon.
- Under the Code option, click Visual Basic
- Enter the following code and click Save.
Run the Macros in Excel
- Go to Developer options in the ribbon.
- Under the Code option, click Macros.
- Select your Macro and Click Run.
- Type in your custom footer, click OK.
- Now you should be able to see your text on your footer.
Visual Basic Editor
Microsoft Visual Basic for Applications (VBA) enables non-programmers to record, create, and edit macros that can automate tasks in Office applications. Excel’s Visual Basic for Applications editor is a tool that enables you to write and edit custom scripts that automate actions in Excel.
Writing a macro from the VBA editor is more flexible than recording a macro.