How to create macro in excel Level of difficulty:
Macros can be defined as single, user-defined command that is part of an application and executes a series of commands. It is a shorthand representation for a number of lines of code. Materials Needed:
- Specialized software
Macros can be created in Excel by the use of a Macro recorder. 1) First of all open up the workbook (file) where the macro has to be used . by clicking on Start>Programs>Microsoft office>Microsoft Excel to open the application.
Go to Start>New to open a new spreadsheet. Go to File>Save as and save the new file
Go to Tools>Macro>Security, and a pop up window named 'Security' will appear. Select the Medium option under the Security Level tab and click OK to continue.
Then click on Tools, hover over Macros and then select Record new macro from the menu.
Now the Record Macro dialogue box appears.
The macro name has to be specified.
A Shortcut key is required which is optional. This has to be a letter, For example p so in our example the macro will run every time we hold down the CTRL key and press the P key. Saving your macro – Macros have to be saved on the workbook on which one is working but one can save macros into a personal macro workbook. Description - A description of the macro for convenience can be given. Click the OK button to start the macro recorder after finishing these steps.' Now the most interesting part is that whatever work is done in the workbook will be recorded. When you have finished click on the small blue square within the macro recording box to stop recording.
In this step we will test that the 'ht' macro works. Go to File>New to open a new spreadsheet. Then, press the Control key and 'P'key at the same to activate the macro. Please note that you can also go to Tools>Macro>Macros and select this macro from the 'Personal Macro Workbook' to run it.
Creating macro using Microsoft Visual Basic On the Tools menu in Microsoft Excel, point to Macro, and then click Visual Basic Editor. On the Insert menu, click Module. Type or copy your code into the code window of the module. If you want to run the macro from the module window, press F5. When you're finished writing your macro, click Close and Return to Microsoft Excel on the File menu.