Microsoft Excel is the one of the most popular spreadsheet programs used worldwide. It has a variety of features such as data storage, creating reports and charts, using mathematical functions, performing statistical analysis, ability to connect to databases, making use of pivot tables, V-lookups etc. One such very useful feature within Microsoft Excel is the ability to make use of “macros”.
What is a Macro?
A macro is a recording of the commands and actions which are used in order to perform a task. Whenever you find that there is a particular task or series of tasks which you perform often, it may make sense to save the sequence of tasks as a macro for reuse later. Thus the applications of Macros to perform frequently occurring repetitive tasks can help free up your time to be spent more productively on doing something else instead.
How to Create Macros
There are two ways of creating macros within Microsoft Excel
1. The first is the Macro Recorder. Excel provides the ability to create macros by creating a recording of the tasks performed by the user. The Macro recorder is usually made use of for simple macros.
2. The second is using the macro editor which is used when complicated macros are required.
The Macro section can be accessed from within the View tab or the Developer tab in the Ribbon in Microsoft Excel.
Recording a Macro
The sequence of steps below details how to record a macro in Microsoft Excel
1. Open Microsoft Excel by clicking on Start>Programs>Microsoft Office>Microsoft Excel. Alternatively, go to Start>Run and type excel and hit the Enter key.
2. Navigate to the Macros section by clicking on the View tab in the Ribbon. Then select the Macros button.
3. A drop down menu appears in which View Macro and Record Macro options are available.
4. Click on the Record Macro button. A dialog box appears
a. Provide a suitable name for the macro.
b. Set a shortcut key for the macro (if required).
c. Choose where to store the macro, within ‘this workbook’, in a ‘new workbook’ or in a ‘personal macro workbook’. By default, it will be ‘this workbook’.
d. Give a detailed description (if required).
5. Perform the series of actions which you want saved within the macro. This step is very important and must be performed without any error because even the errors will get recorded as part of the macro.
6. Once you are done performing the steps required, click on the Macro button and choose Stop Recording from the drop down menu.
7. In order to run a saved macro, choose the Macro button and click on View Macros. A dialog box appears from which the required macro can be selected and run by clicking the Run button. Alternatively, if you know the keyboard shortcut assigned to that macro while creation, you can make use of the shortcut. Click on the Edit button to open Visual Basic Editor to edit the macro’s code. Click on Step Into to run the macro in Debug mode. Use the Delete key to delete unwanted macros.
Microsoft Excel File Type for Macros
Prior to Office 2003, macros could be used as part of just about any excel file. The normal excel format, .XLS could also store a macro. There was an option to enable or disable macros which needed to be set as required.
However post office 2003, with the introduction of the .XLSX format, Microsoft introduced a separate excel for Macro-enabled excel files known as .XLSM. Therefore, if you wanted to create and use macros within an Excel file, it had to necessarily be stored as .XLSM file. This can be seen while saving the file. Choose the Save as file type Excel Macro-enabled Workbook.
Whenever you open an .XLSM file, by default macros are disabled. This is to protect users from unknown content. Click on the Options button and select Enable his content in order to enable the use of macros in your spreadsheet.