How to create a simple macro in Microsoft Excel


It is always a good idea to have a solution for repeated tasks. This is where macro comes in. There are many repeated tasks when working with MS Excel. For example, coloring important cells, adding a comment to many cells, adding values, you name it. If you have an Excel sheet with huge data, or if you have to color important cells in multiple Excel sheets, then you can always make use of the macro feature in MS EXcel.

The extent to which you can automate spreadsheets using macros is huge. In fact it is a subject by itself. Let's take a look at how to create a simple macro, just so you understand how to create macros. You can dig deeper and play around once you have an idea of how to create and edit macros.



From the menu options in MS EXcel click on View :








Then find Macros from here and click on it :











Click on Record Macro from the drop-down :









You'll get a new window with options to enter a Macro Name (spaces not allowed), a shortcut key and some description :
















Click OK and perform the task that you want to create a macro for. It could be anything. This will record an activity. In our example, we can use cell coloring :


















Once the task is completed, then you can go to View -> Macro -> Stop Recording. The activity gets saved and the shortcut key is assigned to the task. Be careful not to use commonly used shortcut keys like Ctrl+C or Ctrl+S, etc.











 
Now you can use the shortcut key to perform this task anywhere on the spreadsheet. Just select a cell or multiple cells and use the shortcut key and you have the task performed without the need to pick up the mouse and click or use the keyboard to type repeated values.




















If you would like to go deeper into macros, then you can use VB programming to tweak your task the way you want it and make it creative and impressive.


From Macros, select View Macros :












Select the macro you want to enhance and click Edit : 




















You'll see the code behind the macro you created. This code is generated automatically, but you can add your magic to it if you want :




























You can take macros to your wildest dreams and become a hero among your colleagues and boss.


Good luck.

No comments:

Post a Comment