Where to begin learning Visual Basic For Applications (VBA) ?

 


The simplest macro in Visual Basic for Applications (VBA) in Microsoft Excel is as per the code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Option Explicit
 
Sub Hello_World()
'---------------------------------------------------------------------------------------
' Procedure : Hello_World
' Author    : vsmathur-onms
' Date      : 17/10/2019
' Purpose   :
'---------------------------------------------------------------------------------------
'
 
   On Error GoTo Hello_World_Error
 
    MsgBox "Hello World !!", vbOKOnly
 
Hello_World_Exit:
 
    On Error GoTo 0
    Exit Sub
 
Hello_World_Error:
 
    MsgBox "Error " & Err.Number & " on Line # " & Erl & " (" & Err.Description & ") in procedure Hello_World of Module m_HelloWorld"
    Resume Hello_World_Exit
 
     
End Sub
Hello World Macro Step 1
Step 1 – Create Shape or WordArt on Worksheet
Hello World Macro Step 2
Step 2 – Clicking the WordArt Image executes the macro.

Comments