How to Record, Run and Save Macro
Welcome to the KalpTalk.
So, let’s learn how to record the macros first…
First of all, go to the Developer tab, then select the Use Relative Reference (means relative to the currently active cell, so caution with your active cell choice when recording a macro and run it), and then click on Record Macro.
When you click on the record macro, there will open one dialogue box called “Record Macro”.
1. You can change the name of the macro as per your choice, by default is named “Macro1”. Here in the example, I have given the name Colour.
2. Then you have to give Shortcut Key, you can choose from CTRL-A to Z OR CTRL+SHIFT- A to Z but choose wisely as there are already built-in shortcuts in the Excel-like CTRL+S for saving the file, CTRL+B for changing the font in bold, CTRL+F to find something in worksheet etc. I have been chosen CTRL+SHIFT+Q for example.
3. Then store the macro in this workbook.
4. If you want to give a description of your macro you can give the description about what it indicates. I give a description that “This macro will colour the cell”.
Do not forget the Shortcut key set in the macro.
After completing this press OK and then run the process exactly what you want by pressing the shortcut key after recording the macro. Like I have been recorded a macro for colour the cell, so after pressing OK it will redirect to the active sheet then I click on the cell I want to colour, change the background colour. And then stop click on the Stop Recording. Now you can press the shortcut key and it works well.
I record the macro and run it…
So, you know very well that every macro we record and run in the Excel generates VBA code, so here is the code generated by macro in the VBA I run in the example.
You will not understand the code to find first time if you are very new in VBA but when you go ahead this all seems easy for you.
Now, how to save the workbook with macros...
So, if you have the Excel workbook without macro it looks like,
And after recording and running a macro in the Excel workbook, click on the SAVE button or CTRL+S, you will get the message as below...
So, to save the workbook with macros click on No button, and then from dialogue box “Save as type”, choose “Excel Macro-Enabled Workbook (*.xlsm). So the file with macros has the extension “.xlsm”, click OK to save the file.
You can see in the image that, the file has an extension “.xlsm”, and the additional symbol indicates that file is macro enabled.
You understand well that how macro generates the code in VBA.
I hope you understand that how Macros work?
Try to Record, Run and Save your own macro.
Thanks for reading, you can read further topics in the other articles.