How to Create a Macro in Excel 2010, 2007 & Above

What is a macro in excel?

This is a fine option that can be used to learn Excel VBA Macro. When the “Record Macro” in switched ON:

Manual operation done to excel are captured and

Each steps is Converted to corresponding Excel VBA code.

This way we have 2 in 1 benefit.

Recorded steps can be played any time.

Generated Code will give us lot of hints on how to write a VBA Macro.

VBA developers use this option to find the syntax of any manual options done in excel sheets (Example: Highlighting a cell with specific color, deleting a row, copy data from a sheet to another sheet etc., )

In Excel 2003 record macro option is easy to find. In 2007 or above, use the below explained options.

Click the “Record Macro” button & it will display a pop up to enter the Macro options.

Here, “Macro Name”, “Shortcut key” and other options can be assigned to the macro which we are going to create now.(Example to Assign Shortcut key to macro: If you want the recorded macro to be played by using “Ctrl+q”, assign “q” in the short cut key option in below window)

Once options are typed, press Enter to start recording. Now the manual actions done to excel will be converted to corresponding VBA (Visual Basic for Applications) Code.

For example: Click on Sheet 1, Cell A1 and change its background color to “Yellow”.

3. Pause or Stop Recoding:

Now macro is in RECORD mode, when the icon changes to shape a square button.

At this point whatever task done in the excel workbook is recorded. Click again on the icon in screen shot to stop recording.

How to Run Created Macro and Edit it in VB Editor?

Now that we have recorded the manual actions done on excel. But, how are we going to re-execute or edit the code auto generated?

To run the recorded macro either use Shortcut key if you have assigned one or refer step 1 again and add “Run Macro” Command to Quick Access toolbar.

This is how a Macro can be created in Excel by enabling the “Record Macro” option from Developer Tab. In long course of time as a Macro developer, the option explained in this page will be very much helpful, when we don’t know the syntax for any commands.

Kumarapush has experience in IT industry for 12+ Years including 10 Years in MNC. Has vast expertise in Microsoft Excel automation using VBA Macro. Excel to CSV converter is one of his famous tool that has been downloaded & used by 68,000 users around the globe.