What is Macros?

A Macros is a piece of programming code that runs in excel environment, and it helps to automate routine tasks. In other words, a macro is a recording of your regular steps in excel, which you can replay using a single button.

What is Macros

Importance of Macros in Excel

You can import the data into the format and excel. Every day you will be required to perform the same ritual. It might become boring and uninteresting.

Macros solve such problems by automating these routine tasks. so you can use a macro to record the steps of

  • Importing the data.
  • And you are formatting it to meet your business reporting requirements.

Macros Basics

Macros are one of the developer features. But the tab for developers is not displayed in excel. So, you will need to present it via the customize report.

Macros are used to compromise your system by attackers. They are disabled in excel. If you want to run macros, then you will need to enable running macros and only run macros that you believe it comes from a trusted source.

If you want to save the macros, then you must protect your workbook in a macro-enabled format *.xlsm and the macro name should not contain any spaces.

How to Write Macros

Let’s see how to write a simple macro in a step by step manner such as:

Step 1: Go to the File → Options in excel.

Step 2: Click on the Customize Ribbon tab and select the Developer.

Step 3: Click on the OK button.

What is Macros

Step 4: Create a folder in drive E named tutoraspire.

Step 5: And paste the annual-enterprise-survey.csv file that you downloaded.

What is Macros

Step 6: The Developer tab appears in the menu bar.

Step 7: Click on the Developer bar.

What is Macros

Step 6: And click on the Record Macro.

What is Macros

Step 7: A dialog box will appear to you.

  1. Enter the macro name.
  2. Store macro is entered by default.
  3. Enter the description, as shown in the below screenshot.
  4. Click on the OK button.

What is Macros

Step 8: Click on the Data tab.

Step 9: And click on “from text” button.

Step 10: Then you will get the dialog window shown in the below screenshot.

  1. Go to the local drive where you stored the CSV file.
  2. Select that CSV file.
  3. Click on the Import button.

What is Macros

Step 11: After that, you will get the Text Import Wizard window.

  1. Click on the Delimited checkbox.
  2. Also, select my data has headers option.
  3. Click on the Next button.

What is Macros

Step 11: Select the Comma options as a delimiter and click on the Next button.

What is Macros

Step 12: Then,

  1. Select the General option.
  2. And click on the Finish button.

What is Macros

After completing above all steps, you will get your workbook shown in the below screenshot:

What is Macros

To finish the macro, click on the Stop Recording macro option as shown in the below screenshot.

What is Macros

Step 13: Click on the Macros button.

  1. Select that macro named importMacro1.
  2. Click on the Run button.

What is Macros


Next TopicVBA Data Types