VBA – Excel Macros

  • Post author:
  • Post category:VBA
  • Post comments:2 Comments

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’.

macro

Step3 βˆ’ The ‘Developer’ ribbon appears in the menu bar.

Step4 βˆ’ Click the ‘Visual Basic’ button to open the VBA Editor.

macro

Step5 βˆ’ Start scripting by adding a button. Click Insert β†’ Select the button.

Step6 βˆ’ Perform a right-click and choose ‘properties’.

Step7 βˆ’ Edit the name and caption as shown in the following screenshot.

macro

Step8 βˆ’ Now double-click the button and the sub-procedure outline will be displayed as shown in the following screenshot.

Step9 βˆ’ Start coding by simply adding a message.

Private Sub say_helloworld_Click()
   MsgBox "Hi"
End Sub

Step10 βˆ’ Click the button to execute the sub-procedure. The output of the sub-procedure is shown in the following screenshot. Make sure that you do have design mode turned on. Simply click it to turn it on if it is not on.

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.

Next Topic:-click here

This Post Has 2 Comments

Leave a Reply