What is VBA

VBA stands for Visual Basic for Applications is a programming language created by Microsoft that you can use to extend the default functionality of Microsoft Office Applications like Word, Excel, Access and Powerpoint etc. using VBA code, you can automate many of the tasks that you regularly and repetitively perform.

In simple words, VBA lets you write small programs, called “macros” that can perform repetitive or complex tasks automatically.

One of the key advantages of using VBA (Visual Basic for Applications) is it saves a lot of time. Instead of doing the tasks manually repetitively, which can be tedious and time-consuming, VBA allows you to automate the process.

How to use and run VBA Code:

VBA code can be executed through the VBA Editor, which can be accessed using three different methods.

  1. Using the Developer Tab – Click on the Developer tab in the Ribbon, then select Visual Basic to open the editor.
  2. Using the Keyboard Shortcut (Alt + F11) – Press Alt + F11 on your keyboard to quickly launch the VBA Editor.
  3. Using the Macros Dialog Box – Go to View > Macros > View Macros, select a macro, and click Edit to open the editor, or create a new one.

Let’s take a closer look at each of these three methods in detail below.

1. Using the Developer Tab

The Developer Tab or Developer Options in Microsoft Office applications (like Word, Excel, Access & PowerPoint) offer additional powerful tools and options for automating tasks, protecting document from unauthorized access, creating interactive forms, macros, writing custom VBA code, and managing add-ins. It is primarily intended for developers, but even advanced and power users can benefit from these features to boost productivity and expand the capabilities of Office applications. Here in this tutorial, I am going to explain, how to enable developer tab in Office Applications (Like Excel, Word, Access & PowerPoint).

How to enable Developer Tab:

The Developer tab is not visible by default in most Office applications (like Word, Excel, PowerPoint).

on ribbon developer mode is not visible

From the above screenshot you can see that, developer tab is not present/visible on the ribbon.

To make the Developer Tab visible on Excel Ribbon follow these steps:

  1. From the Menu OR Ribbon Click on File Tab
  1. Click on Options.
  1. In the Excel Options (or Word Options, Access Options, PowerPoint Options) window, Click on Customize Ribbon, On the right side, under the Main Tabs section check the box for Developer. And Click OK button to apply the changes
enable developer mode in excel option dialog box

And finally, the Developer Tab will be will visible on the Excel Ribbon.

developer tab is enable on ribbon

The same procedure can be used to enable the Developer Tab in other Microsoft Office applications such as Word, Access, or PowerPoint.

after enabling developer tab.

  1. Open the Visual Basic for Applications (VBA) editor or IDE by
    Clicking on Developer tab then from the Code Group the Click On Visual Basic as shown bellow.
developer tab on ribbon

OR by Pressing Alt + F11 (Alt plus F11) shortcut Key from your Keyboard.

2. Using Keyboard Shortcut (Alt+F11)

Just press Alt+F11 Shortcut Key and VBA Editor will opens up.

VBA IDE(Integrated Development Environment) will opens up as bellow.

VBA Editor
  1. In the VBA editor, from the menu click on Insert > then click on Module to create a new module.
Insert New Module in VBA IDE
  1. Paste or write the code into the module.
Writing Code in VBA Module
  1. Click On Save icon (or Click on Run Icon or Press F5 Keyboard Shortcut to RUN the Code) and Close the VBA editor.
Save, RUN and Close VBA Editor

3. Using Macros Dialog Box

Click on View Tab > then from the Macros Group Click on View Macros or Just Press Alt+F8 Keyboard Shortcut, Macros Dialog Box will appear as shown bellow

after clicking on Create button VBA Editor will opens up

Executing VBA Code

You can run VBA code directly within the VBA Editor by pressing Alt + F5, or execute it later from the Macros Dialog Box after saving and closing the editor, as explained below

Executing VBA Code from Macros Dialog Box

Press Alt+F8 to display the list of VBA macros, then select your created macro, and click on Run Button.

    Micro Dialog Box to Execute VBA Micros

    And finally, your VBA Micro will be executed.

    Message Box after VBA Micros Execution

    This is how you can use and execute or run VBA Code in Microsoft Word, similarly you can use and run VBA Code in other applications of Microsoft Office such Excel, Access, and PowerPoint.

    I hope this tutorial will help you to know how to use VBA Code. if you have any queries, suggestion or feedback feel free to contact us.

    Benefits of VBA

    • Save time
    • Reduce errors
    • Automate everyday tasks
    • Make complex formatting and data analysis easier

    Frequently Asked Questions (FAQs)

    1. Is VBA available in all versions Microsoft Office?

    Yes, VBA is available in almost all desktop versions, including Office 2016, 2019, 2021, and Microsoft 365.

    2. Can VBA code run in mobile or web versions?

    No VBA Code is not run in mobile web versions, VBA only runs in desktop versions of Windows or macOS.

    3. Do I need to know programming to learn VBA?

    No, not at a basic level. You can start with simple examples and learn gradually.

    Leave a Reply

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