A macro helps to automate tasks that you do repeatedly in excel. Take it as an algorithm with a set of instructions to follow and can be run several times.
Create a macro with VB
1. Click on the View tab
2. Click on the Macros Option.
3. In the 'Macros window,' type a name for the new macro.
4. Select the location you want your macro applied to.
5. Click the Create button.
6. The Microsoft VBA window will open. Here type in the Visual Basic Code manually to create the macro.
7. Click on the Save icon in the menu bar and close the VBA window.
Using Developers tab to create a Macro
To enable and create a macro, let's start first with how you get to install the Developers tab on the main menu ribbon.
1. Under the Microsoft Office Suite package, open Excel
2. Go to the File ribbon and click on the Excel Options tab.
3. From the dialogue box displayed, click on Customize Ribbon option.
4. The dialog box is divided into two. Go to the right side box and check the Developer checkbox. The box will be in the list found on the right side.
5. Click OK. After clicking this option, the Developer tab will appear at the end of your main menu ribbon lists.
After completing the above steps, lets us look at the steps to follow when you want to record a macro.
Recording a Macro
First of all, you have to know macros record your mouse clicks and anything you do. It is advisable to be sure of the commands you want to record to avoid making mistakes and ruining the whole process.
1. click on the Developers tab.
2. Under the Codes group, select the Record Macro option.
3. You can also decide to use the keyboard shortcut Alt+ T+ M+ R. Both actions will display a dialogue box.
4. Type in the name of the macro under the 'Macro Name' field. Make sure to use a name you can remember, especially if you plan to record many macros.
5. Check the 'Shortcut Key' box to assign your macro a keyboard shortcut. For example, select B, and anytime you want to run your macro, press on Ctrl + Shift + B.
6. under the 'Store macro in" field, select your current workbook or any preferred option. For example, you can choose 'Personal Macro Workbook' if you want the macro to be available in any spreadsheet you work with.
7. Click OK to start recording your macro.
8. On your worksheet, start performing the macro you want to record. Keep in mind that everything you do in that worksheet will be recorded as a macro.
9. Click Stop Recording when done and save your macro. Remember to save your worksheet as a macro-enabled format when you finish up with it. In case you want to run the macro, let's proceed to the steps below.
How to Run Macros in Excel
1. In your macro-enabled open workbook, press the macro keyboard shortcut to run it.
2. Or go to the Macros button in the Developer tab. On the displayed dialogue box, click on the macro you want to run.
3. Click the Run button.
Conclusion
Creating, recording, and running Excel macros involves several steps. Despite this, it has many benefits, and once a user does it consistently, they get the hang of it.
Once you've created macros that you can use in different spreadsheets, you will save time while working with your spreadsheets.