Excecl VBA Classic Excel VBA 2010 Excel VBA 365 Excel VBA Examples About Us

Lesson 1 Introduction


🧩 What is Excel VBA?

Excel VBA (Visual Basic for Applications) is a powerful programming language built into Microsoft Excel that allows users to automate repetitive tasks, customize Excel functionalities, and build advanced solutions like user forms and dashboards.

With VBA, you can:

  • Write macros to perform tasks automatically
  • Create custom functions beyond Excel’s built-in formulas
  • Interact with other Office applications like Word and Outlook
  • Develop interactive tools such as buttons, drop-down lists, and forms

Think of VBA as Excel’s built-in coding engine that empowers users to take control of spreadsheets and streamline complex workflows.

🚀 Why Learn VBA in Excel 365?

Learning VBA in Excel 365 gives you a major productivity boost, especially in today’s data-driven workplaces.

Here are 5 great reasons to learn VBA in Excel 365:

  1. Automate Repetitive Tasks: Eliminate manual work by writing macros that perform tasks like formatting, data entry, and report generation—saving hours every week.
  2. Boost Your Excel Skills: Understanding VBA unlocks hidden features in Excel 365 and enhances your data analysis capabilities.
  3. Create Custom Solutions: You can build tools tailored to your specific needs—such as invoice generators, dynamic dashboards, and data import/export utilities.
  4. Improve Job Prospects: Employers highly value VBA skills for roles in finance, data analysis, engineering, and business operations.
  5. Work Smarter, Not Harder: Excel 365 integrates with cloud features and Power Query, and VBA adds another level of automation that makes your spreadsheets smarter and more interactive.

In short: Learning VBA makes you a power user—enabling you to do more with Excel in less time.

🛠️ Step-by-Step: Writing Your First Macro

Let’s walk through how to create your very first Excel VBA macro using the built-in Visual Basic for Applications (VBA) editor in Excel 365.

🔹 Step 1: Open the Developer Tab

Before writing any macro, make sure the Developer tab is visible in the Ribbon:

  1. Go to File > Options.
  2. Select Customize Ribbon.
  3. Check the box for Developer, then click OK.

Refer to Figure 1.1 showing the Developer tab added to the Ribbon.

Figure 1.1

🔹 Step 2: Launch the Visual Basic Editor

Click on the Developer tab, then select Visual Basic. This opens the VBA Editor, where you can write and manage your macro code.

Excel VBA Editor
Figure 1.2 Image: The VBA Editor interface in Excel 365.

🔹 Step 3: Insert a Module

In the VBA Editor:

  1. Right-click on VBAProject (Your Workbook Name) in the left pane.
  2. Choose Insert > Module.

This opens a new code window, ready for your macro, as shown in Figure 1.3.

Figure 1.3

🔹 Step 4: Write Your First Macro

In the module window, type the following code:

 Private Sub Worksheet_Activate()
 MsgBox "Welcome to Excel VBA 365"
End Sub
 

This simple macro displays a message box that says "Welcome to Excel VBA 365", as shown in Figure 1.4

Figure 1.4

🔹 Step 5: Run the Macro

  1. Close the VBA Editor and return to Excel.
  2. In the Developer tab, click Macros.
  3. Select HelloWorld from the list and click Run.

A pop-up message will appear — Congratulations, you’ve just run your first VBA macro!

💡 Tip:

Always save your workbook as a Macro-Enabled Workbook (.xlsm) to preserve your macros.



Copyright ® 2020 Dr.Liew Voon Kiong . All rights reserved   [Privacy Policy]

Contact: Facebook Page