What is Excel Macro?

What is a Macro in Excel?

A Macro is a re usable tiny program which we can save and run to repeat the same action or tasks in Excel. We can create a macro to perform an action or set of actions repeatedly. Let us see why we use Macros in Excel? and How to create a macro? And the examples of the Macros in Excel.

Uses of Macros in Excel

We can use the Macros to perform the repetitive tasks and save the process time of a given task. Here are the uses of Macros in Excel.

  • Reproduce Actions: We can use the Excel Macros to reproduce the same action again and again. We can create a macro to perform an action and save it using a macro name. And we can re use the same macro whenever you want to reproduce the same action.
  • Avoid Repetition: Macros helps us to record the actions using Mouse clicks and keyboard. It can record all the actions performed using Mouse and keyboard. You do not need to repeat to do it again. Instead, you can use macros to repeat those mouse actions and keyboard actions.
  • Save Time: As we know that the macros can be called and execute any time and replicate the same action. Macros helps to save the time helps to produce the outputs quickly.
  • Quality: Macros will improve the Quality of the outputs by avoiding human made mistake and reduce the typo errors.
  • Accuracy: Impacts on overall accuracy of any process and produce the accurate outputs to deliver on time.

Creating a Macro

We can create macros in two ways, using Macro Recorder and Using VBA Editor. Let us see how to create a macro in Excel?

Method 1: Creating a Macro Using Macro Recorder

Excel is provided with a ready to use Macro recorder to create macros in Excel. We can record a macros and save and reuse macro recorder command in Developer Tab. Please follow the below steps to create a macro:

  1. Go to Developer Tab in Excel Ribbon Menu
  2.  Click on ‘Record Macro’ Command (Start Creating Macro) in Code Group
  3. Provide a Macro Name (for example: Example_Macro_1) which suites your task
  4. Perform required action using Keyboard or Mouse
  5. Click on ‘Record Macro’ Command Again to Stop Creating Macro

This will create ‘Example_Macro_1’, will be saved in the same workbook with the given name. You can reuse this macro whenever you need to perform the same task.

All the macros which are are created using Macro Recorder are VBA Programs. Macro recorder will help to quickly record a macros using built-in commands in Excel. It produces the statements for all the steps performed using Mouse and Keyboard. All the names of the objects and cell references will be fixed when you create a macro using Macro Recorder. You can use VBA Editor to modify the macros which are produced by Macro Recorder.

Method 2: Writing a Macro Using VBA

Alternatively, we can write a macro using VBA. VBA is Macro Programming Language provided in all MS Office Applications to create our own Programs to automate the tasks and create tools and enhance the existing features and functions.

Here are the steps to write a macro using VBA.

  1. Go to Developer Tab in Excel Ribbon Menu
  2.  Click on ‘Visual Basic’ Command in Code Group, This will launch the VBA Environment
  3. Insert a Module from Insert Menu
  4. Start writing your macro (Macro should start with Sub and Your MacroName)

For Example: The following macro will show you ‘Hello World’ Message Box.

Sub FirstMacro()
     MsgBox "Hello World"
End Sub

Examples

Leave A Comment