An Interactive Learning Tool

Proud to be a Teacher

Recording a Macro

When you have data that you need to treat in the same way all the time. for example to insert columns on specific locations or to delete some specific type of rows and data come in same format and you just need to sanitize or calculate in a specific manner you can record a macro.
How to Record:

Click on the developer tab. If developer tab is missing please use above said way to visible developer tab.

In the copy group click Record Macro

Below window will be appeared

Give a name your macro

Give a shortcut key and click Ok.

Start doing your process you want to be repeated every time within the excel worksheet. When you have finished. Stop recording macro using Stop Recording button.

To use this recorded macro, click on macros

Macro list window will be appeared

Select your macro and run


Although the Excel macro recording feature is a very simple way of creating VBA code, it can only be used for very basic macros. This is because it cannot make use of many VBA features, such as :
Defined Constants, Variables and Arrays;
If Statements;
Calls to Built-In Functions or Other Procedures.

Also, the recording tool can only produce Sub procedures (not Function procedures), as it cannot return a value. These Sub procedures cannot be passed any arguments, although they are able to identify the current active cells, ranges or worksheets, and values stored in the cells of the workbook. It should also be noted that the code generated is not always the most efficient code possible for the required actions.

Viewing the VBA Code

The VBA code produced by the macro is placed into a module, which can be viewed via the Visual Basic Editor. This can be opened by pressing ALT-F11 (i.e. press the ALT key, and while this is pressed down, press F11).
The code is located in one of the modules in the project window, which is positioned to the left of the visual basic editor. In the simple project window shown on the right, you could view this code by double clicking on 'Module 1'.

Terms of use Website Policy Contact us
© Copyrights 2020