How to write a MS Excel Macro
76Microsoft Excel is a very handy tool many of us use for our daily calculations. It can be used in simple calculations to advanced data processing. Anybody who wants to master excel, should know how to write an Excel Macro. Basically Excel macros can be used in two different situations.
1.You can write an Excel macro to automate repetitive task
If you happen to perform same set of calculations, formatting over and over again on different sets of data you can think of writing an excel macro to automate that process.
Consider the following example
For the above worksheet the data is entered after completion of an exam. Then the total, average marks and the final grade of each student should be calculated. At the same time the grade column should be conditionally format to highlight the failed students. All the above calculations should be repeated when marks for a new exam is entered. This is the unnecessary repetition and we can avoid it by writing an Excel macro.
2. To achieve some advanced functionality which is impossible using the standard functions in Excel, we can write an Excel macro.
Consider the following situation
Here the requirement is to check whether the employees work according to their work agreement. The agreement does not permit to work in two consecutive shifts. How can you highlight the violation of the agreement? You can’t use the excel functions available to accomplish this situation. The answer is to write an Excel macro.
In this article let’s see how we can record a macro to avoid the repetitive tasks.
Insert the Developer tab to the Ribbon
All macro related options are available in Developer tab of Excel 2007. To add the developer tab to the ribbon click Office Button ->Excel Options and select Show Developer tab in the Ribbon.
Now the Developer tab should appear on the Ribbon.
Record the macro
Now you can record your macro. Here what you will be doing is performing the actions that you want to perform on the data that you have entered. They may be formatting cells, conditionally formatting or calculations. You have to record them in the exact order in which they should run when the macro is run.
To record the macro click on Record Macro in the Developer tab. Then you will be asked to give a name to your macro and a shortcut key. The short cut key can be used to run the macro lator.
Recording the macro
Now whatever you will be doing is recorded to the macro. Once you have completed recording click Stop Recording Macro to stop recording.
Run the Macro
Now everything is Ok and you can test your macro in action. Click on Macros in the Code group of Developer tab. All the macros that are available will be displayed. Select the macro you recorded just before and click Run. The macro will run and all the formatting and calculations will be done at once! That is so easy
Excel Macro Guides
![]() | Amazon Price: $12.98 List Price: $29.99 |
![]() | Amazon Price: $47.99 |
![]() | Amazon Price: $29.99 List Price: $99.99 |
![]() | Amazon Price: $136.29 List Price: $199.99 |
![]() | Amazon Price: $0.99 |
Other Excel related hubs
- How to write a MS Excel Macro
Microsoft Excel is a very handy tool many of us use for our daily calculations. It can be used in simple calculations to advanced data processing. Anybody who wants to master excel, should know how to write an Excel Macro. Basically Excel macros... - 15 months ago
- Writing excel macros- the simple way
MS Excel is a great tool to use in day to day data analysis. The excel functions and other nice features will do a handy job for you. But if you know a little bit of writing excel macros then you can add immense power to your excel work sheets. By... - 15 months ago
- Excel Shortcut Keys
As you all are aware shortcut keys are available in any computer application to make the task easier. There is no difference in excel, there are plenty of excel shortcut keys. If you know Excel shortcut keys,... - 16 months ago
- How to create pulldown list in Excel 2007
Many of us use Microsoft Excel for our day to calculations. But how many of you know how to create drop down down list Excel 2007. I am talking about something which is shown in the following figure. Data... - 16 months ago
- 50 Reasons to upgrade to Microsoft Excel 2007
Software changes all the time. So we have to go with the change most of the time either we like it or not. Upgrade from Office 2003 to Office 2007 is the same story. There are many who loves the new version... - 16 months ago
CommentsLoading...
Really sorry - link should have been http://www.wiseowl.co.uk/blog/s137/recording-macro - full stop (or period to Americans) at end stopped previous link working!


![Total Training for Microsoft Excel 2010: Advanced [Download]](http://ecx.images-amazon.com/images/I/513nNzKTnaL._SL75_.jpg)











AndyOwl 10 months ago
Good article. There's a blog which expands further on recording macros in Excel (particularly 2007/2010) at http://www.wiseowl.co.uk/blog/s137/recording-macro