How to Insert & Run VBA code in Excel – VBA101

How to Insert & Run VBA code in Excel - VBA101
Table of Contents

Background

This step-by-step tutorial is for absolute beginners in VBA. You don’t need to have any expertise to be able to follow this tutorial. When I was learning Excel at the very beginning, every single Excel functions excited me a lot. Index Match and Vlookup get me wonder how powerful is Excel. When I found out about VBA, I was mind-blowing. I was so amazed at what I can accomplish with VBA. I highly suggest everyone to learn a bit of VBA.

Why you should learn VBA

  1. To appear to be smart and tech-savvy
  2. To keep up with the pace in current days (now kids start to code at primary school)
  3. To polish your resume
  4. To kill repetitive, manual, time-consuming task
  5. To get the most of Excel

In Dollar Excel, we have published a number of articles about VBA but we didn’t really touch on the basics in our previous articles. In this article, I am going to walk you through the fundamentals – how to insert and run VBA code in Excel.

To be honest, different people have different talents and interests. I am not here to persuade everyone to learn coding but I do think learning the basic can be very useful. You don’t need to know how to produce the code. You don’t need to figure out the meaning of every elements and parameters. However, you do need to learn where to paste your code and which button to press in order to run a piece of code.

Step-by-step Tutorial

Read How to Enable Developer tab in Excel? if you haven’t enable Developer tab yet.

Step 1: Open a Excel Workbook

Step 2: Press Alt + F11 to open the Visual Basic Editor (VBE)

Shortcut to open Visual Basic Editor (VBE)
Shortcut to open Visual Basic Editor (VBE)

After pressing the shortcut, you should see this window.

Visual Basic Editor (VBE)
Visual Basic Editor (VBE)

Step 3- 5: Right click your workbook and select “Insert”, then select “Module”

In the left panel, you should be able to find your workbook.

What is Module?

A module is where you insert your VBA code. If you find it confusing, just treat it like a folder.

Right click your workbook and select "Insert", then select "Module"
Right click your workbook and select “Insert”, then select “Module”

Now you will see the module 1.

Module 1
Module 1

Step 6: Paste your code into the window

Here I am using the code from How to Go to a Specific Excel Sheet. You can check out the article and practice with the code provided in the article.

Paste your code into the window
Paste your code into the window

Step 7: Press F5

Press F5
Press F5

Congratulations! You just did it! Now you can play around with other VBA codes available at our website!


Do you find this article helpful? Subscribe to our newsletter to get exclusive Excel tips!

International Open Academy

Join Our Newsletters!

JOIN OUR NEWSLETTERs!