0

VBA Introduction – Getting Started in the VB Editor

VBA stands for Visual Basic for Applications, is an event-driven programming language from Microsoft.

In this tutorial, you will learn following,

  • How to Access the Visual Basic Editor?
  • How to add and rename a command button?
  • How to write VBA Code for the command button?

How to Access the Visual Basic Editor?

Before you can start writing code, you first need to open Visual Basic Editor.

Step 1 – First, enable ‘Developer’ menu in Excel, to do the same, click File → Options.

Step 2 – Click ‘Customize Ribbon’ tab and check ‘Developer’. Click ‘OK’.

VBA developer

Step 3 – The ‘Developer’ tab appears in the menu bar. Click ‘Visual Basic’ to open Visual Basic Editor.

VBA Visual Basic

VBA Visual Basic Editor

How to add and rename a command button?

Step 4 – Click Insert → Select button

VBA button

Step 5 – Right-click on button and choose ‘Properties’

VBA Properties

Step 6 – Edit name and caption for the button as shown below

VBA Name

How to write VBA Code for the command button?

Step 7 – Double-click on the button and the sub-procedure will be displayed.

Step 8 – Add code ‘MsgBox “Hellow”

VBA Code

Step 9 – Click the button and the result will be as shown below.

VBA result

 

 

 

Leave a Reply

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