VBA – Excel Macros

In Excel window, press “ALT+F11”. A VBA window opens up.

In this chapter, you will learn how to write a simple macro in a step by step manner.

Step 1 − First, enable ‘Developer’ menu in Excel 20XX. To do the same, click File → Options.

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

Developer in VBScript

Step 3 − The ‘Developer’ ribbon appears in the menu bar.

Developer in VBScript

Step 4 − Click the ‘Visual Basic’ button to open the VBA Editor.

Developer in VBScript

Step 5 − Start scripting by adding a button. Click Insert → Select the button.

Developer in VBScript

Step 6 − Perform a right-click and choose ‘properties’.

Developer in VBScript

Step 7 − Edit the name and caption as shown in the following screenshot.

Developer in VBScript

Step 8 − Now double-click the button and the sub-procedure outline will be displayed as shown in the following screenshot.

Developer in VBScript

Step 9 − Start coding by simply adding a message.

Private Sub say_helloworld_Click()
   MsgBox "Hi"
End Sub

Step 10 − Click the button to execute the sub-procedure. The output of the sub-procedure is shown in the following screenshot.

Developer in VBScript

Note − In further chapters, we will demonstrate using a simple button, as explained from step#1 to 10. Hence , it is important to understand this chapter thoroughly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s