VBA Tutorial

What is Excel VBA Tutorial for Beginners?

You can use a VBA tutorial to improve your skills and work on various projects. In VBA, you can code in some user-defined functionalities in Excel at your convenience. The best part about the VBA Tutorial point is that it is easy for beginners to grasp code.

Consider the following example:

VBA Tutorial - Definition Example - 1

It implements a Message box printing the message.

VBA Tutorial - Definition Example - 2

It is also possible to get a VBA tutorial free of cost by reading Microsoft Documentation or reputed websites that explain VBA code. You can learn VBA tutorial in the way you prefer.

Key Takeaways
  • Macros automate repetitive tasks in Excel. VBA (Visual Basic for Applications) is the programming language used to create Excel macros.
  • Macros are sets of recorded actions or VBA code. VBA allows customization and advanced functionality in Excel.
  • Macros can improve efficiency and accuracy in Excel workflows.
  • Security is important when using macros.
  • Learning VBA involves understanding Excel and programming concepts.
  • Practice and documentation are key to mastering macros and VBA.
  • A good and efficient VBA Tutorial portal is needed to improve and master your skills as a VBA Developer.

What are the Macros in Excel?

Macros in Excel are a powerful feature that allows you to automate repetitive tasks by recording a series of actions you perform in Excel and replaying them whenever needed. Macros are created using Visual Basic for Applications (VBA), a programming language developed by Microsoft specifically for automating tasks in Office applications like Excel. They are important to learn about when searching for a good VBA Tutorial.

Excel macros are a powerful tool for improving productivity and efficiency when working with Excel spreadsheets. They can save you significant time by automating tasks that would otherwise require manual intervention. However, using macros responsibly and being cautious about security when enabling and running them is essential.

The basics you start in a VBA Tutorial is to view and run macros easily. To do so, we need the “Developer” tab. But when you start with Excel, it is disabled by default.

You can include the “Developer” tab by following the steps below:

  1. Go to File.

    What are the Macros in Excel - Step 1a

    Under File, go to Options.

    It will open a window where you can customize many things.

  2. Select Customize Ribbon.

    What are the Macros in Excel - Step 2

  3. Go to “Main Tabs” in the Customize Ribbon option and check the box Developer to enable it.

    What are the Macros in Excel - Step 3

  4. Click on OK to enable it.

    What are the Macros in Excel - Step 4a

    If you check the title bar, the “Developer” tab will be there.

    With the “Developer” tab, you can learn and implement Macro and VBA Tutorial Point into your Excel. View some examples of how to build and enforce Macros in Excel below. Learning VBA Tutorial is beneficial by adding some innovative examples.

Excel VBA – All in One Courses Bundle (35+ Hours of Video Tutorials)

If you want to learn Excel and VBA professionally, then ​Excel VBA All in One Courses Bundle​ (35+ hours) is the perfect solution. Whether you’re a beginner or an experienced user, this bundle covers it all – from Basic Excel to Advanced Excel, Macros, Power Query, and VBA.


Let’s review some interesting cases where you can create macros to start your Advanced VBA Tutorial.

Example #1

You have a table with the values for a right-angled triangle. Here, the values for the base and perpendicular are given.

VBA Tutorial - Example 1

You need to find the hypotenuse of the triangle. To do so, we implement Pythagoras’ theorem.

We know that by Pythagoras’ theorem, in a right-angled triangle, the:

Square of Hypotenuse = Square of Base + Square of Perpendicular

This formula can be implemented in Excel while creating the macro. There is a function to find the square root of a number with the SQRT() function from Excel. The square of a number in Excel can be found by using the “^” symbol after the number with the power coming after the symbol as shown below:


With these in mind, we can write the Excel Formula to find the hypotenuse of the triangle with the formula:


where x and y are substituted with cell values.

Now, you can start creating a macro by following the steps below.

  • Step 1: Click on Record Macro. Go to the Developer tab and click “Record Macro.”
Example 1 - Step 1
  • Step 2: Give Name to Macro.
 VBA Tutorial - Example 1 - Step 2

Here, we find both the Hypotenuse and the area of the Triangle. We know how to find both with formulae.

  • Step 3: Click on OK to start the recording.
VBA Tutorial - - Example 1 - Step 3

Here, the shortcut key to run this macro is Ctrl+Shift+q. Describe the macro so that when others access the workbook, they will not be confused with the available macros.

  • Step 4: Find the triangle’s hypotenuse with the above formula once the recording starts.
VBA Tutorial - Example 1 - Step 4

Now you are done. Stop the recording by clicking “Stop Recording” in the “Developer” tab.

Example 1 - Step 4b
  • Step 5: In the “View” tab, click “View Macros”.
Example 1 - Step 5a

It will open a popup. Click the “Edit” button.

Example 1 - Step 5b

It will open the VBA Editor.

VBA Tutorial - Example 1 - Step 5c

Keep the cursor on the Hypotenuse_finder() subroutine.

  • Step 6: Click the run button on the VBA editor to run the Macro.
Example 1 - Step 6a

Alternatively, use the shortcut keys you’ve defined for the macro. Select the active cell and then press the shortcut keys.

VBA Tutorial - Example 1 - Step 6b

Similarly, drag the values across all the rows.

VBA Tutorial - Example 1 - Step 6c

With this, you have discovered a triangle’s hypotenuse given its values. You have learned one aspect of the VBA Tutorial: performing a Macro on a single row. Next, you must learn how to execute a macro for multiple lines. A good VBA tutorial can teach you how to do that.

Example #2

In a school, you are given a list of students’ marks, and they’ve provided you with the grade parameters and a short description to be added. You will need to automate this so that they can apply the same feature later. It is possible with examples from VBA Tutorial Point.

VBA Tutorial in Excel - Example 2-1

These are the parameters given by the school management, and you’ll have to implement them. Note the cell numbers these are in. The cells will play an important role when you’re recording a macro.

VBA Tutorial in Excel - Example 2-2
  • Step 1: To automate printing the description and the grades of the marks given to you, go to the “View” tab and click the “Macros” button.
VBA Tutorial - Example 2 - Step 1
  • Step 2: If you want to ensure your Macro works for multiple rows, it is imperative that you should turn on relative references. This can be viewed by going into the “Developer” tab and then clicking “Use Relative References”.
Example 2 - Step 2
  • Step 3: Click “Record Macro” to start recording the macro.
Example 2 - Step 3
  • Step 4: Highlight what your Macro will do since you will be sending your Workbook to multiple people, and it will be helpful to let them know what your Macro does. Remembering this is fundamental, especially when you are early into your VBA tutorial.
VBA Tutorial in Excel - Example 2 - Step 4

After editing, click “OK” to continue recording.

  • Step 5: After doing so, go to the “Grade” column and type the formula given at the end of this step.

But before doing so, understand what you are trying to do.

First, we are declaring an IF function in Excel to check the parameters.

=IF($H2=$A$2, $C$2

We use the IF statement to check the values in the parameter table in columns A-D.

We write the formula and the “$” sign to tell Excel these are constant values; hence, they will not change according to the current cell position.

Here, we are declaring the grade for marks 0-100. We compare each student’s marks with the values in Columns A and B and assign the grade in Column C.

It can be done by implementing the AND function and a nested IF statement.

We add another IF statement in the Else part of the first IF function to subsequently return the other grades if one condition fails. For the first Else part, we write the statement,


This block is executed if the first part fails. Here, we move to cell A3, check if the values are similar or are between the numbers 91 and 99, and return the grade as “B” in cell C3. Similarly, add another IF part in the Else section of this code block to check the Else formulae.


This way, the whole formula to find the student’s grade is calculated and printed automatically.

Final Code:

VBA Tutorial in Excel - Example 2 - Step 5a

We do not want the cell values referring to the Parameter table to change. Hence, we use the “$” sign before the number; for example, “$A$2” ensures that the value will always refer to the cell value of A2 regardless of the cell it is called.

Example 2 - Step 5b
  • Step 6: Reflect the grades of the entire row by dragging the cursor down till the last row of the table.
Example 2 - Step 6
  • Step 7: Stop recording the macro.
Example 2 - Step 7a

If we click the “Visual Basic” button, we’ll be able to see the code generated by Excel.

Example 2 - Step 7b
VBA Tutorial - Example 2 - Step 7c
  • Step 8: Similarly, print the values for “Description” in the table.
VBA Tutorial - Example 2 - Step 8
  • Step 9: Use the Formula below to print the description.

It uses the concept like the one explained in Step 5.

VBA Tutorial in Excel - Example 2 - Step 9
  • Step 10: After recording the macro, click on the first row and press the shortcut keys assigned to the macros. Here it is Ctrl+Shift+O and Ctrl+Shift+E. The output can be viewed as shown below.
VBA Tutorial in Excel - Example 2 - Step 10

In this way, you can automate printing values for the table by recording macros.

How to Save Macro Workbook

To save a Macro WorkBook, follow the steps below.

  • Step 1: Go to FILE.
How to save Macro Workbook - Step 1

Select “Save as”

  • Step 2: Select the file or folder you want to save.
How to save Macro Workbook - Step 2

Here, the “Downloads” folder is chosen.

  • Step 3: After selecting the folder, select the file type you want the Excel Workbook to be saved as.
How to save Macro Workbook - Step 3

Since we’re dealing with macros, save it with the file “Excel Macro-Enabled Workbook,” abbreviated as “.xlsm.”

  • Step 4: After making these changes, click “Save”.
How to save Macro Workbook - Step 4a

You can view your file in the “Excel files copy.”

How to save Macro Workbook - Step 4b

Important Things To Note

  • Avoid running macros from untrusted sources to prevent potential security risks.
  • Implement error-handling routines to identify and address issues in your macros. Use the VBA debugger to step through code for troubleshooting.
  • Make backups of your Excel files before running macros, especially if they substantially change your data.
  • Ensure your macros are compatible with the versions of Excel that others may use.
  • Keep macros simple and easy to understand to minimize errors and facilitate maintenance.
  • Test macros on sample data to verify they work as expected before applying them to critical files.
  • Anticipate potential changes to data or requirements and design flexible macros for easier future updates.

Frequently Asked Questions (FAQs)

1. Are VBA and Macros the same thing?

No, VBA (Visual Basic for Applications) is the programming language used to create macros in Excel. Macros are automated sequences of actions created using VBA. But, both of these are learned parallelly when doing a course on VBA Tutorial.

2. Are VBA and Python similar?

VBA and Python are different programming languages with distinct syntax and use cases. You do not need functions to print values in Python, but you’ll need to define a subroutine in VBA.
print(“Hello World”)
Sub PrintALine()
            Debug.Print “Hello World”
End Sub

3. Can VBA be used outside of Excel?

VBA is primarily used within Microsoft Office applications and isn’t typically used for standalone software development.

4. Where to run VBA code in Excel?

You can run VBA code in Excel by accessing the Visual Basic for Applications (VBA) editor within Excel, often found under the “Developer” tab.

In the VBA Editor, press the green arrow button or “F5” to run the VBA code.

 How to save Macro Workbook - FAQ 4

5. What is required to learn VBA?

• Familiarity with Excel: Before learning VBA, it’s essential to have a good understanding of how Excel works, including its functions, formulas, and basic operations.
• Access to Excel’s VBA Editor: You’ll need access to Excel’s VBA editor, which you can find in Excel by enabling the “Developer” tab through Excel’s options or settings.
• Online Tutorials and Courses: Learn VBA Tutorial through online tutorials, courses, or books dedicated to Excel VBA programming. Many resources are available on websites and platforms like Microsoft’s official documentation, YouTube, and educational websites.
• Practice and Experimentation: To become proficient in VBA, practice is crucial. Start with small projects by following advanced VBA tutorials.

Download Template

This article must be helpful to understand the VBA Tutorial, with its features and examples. You can download the template here to use it instantly.

This has been a guide to VBA Tutorial. We learn what are Macros, how to record, use & save them, along with examples & points to remember. You can learn more from the following articles –

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *