VBA Language : An Overview
This Article shows the VBA language elements, which are the keywords and control structures that are used to write VBA routines. Take a look at the following VBA Sub procedure. The procedure, calculates the sum of the first 10 integers. When the code finishes executing, the procedure displays a message with the result.Sub sumint()
' This is a simple VBA Example
Dim Total As Long, i As Long
Total = 0
For i = 1 To 10
Total = Total + i
Next i
MsgBox Total
End Sub
This procedure uses some common VBA language elements, including the following:
- A comment
- A variable declaration statement
- Variables
- Assignment statements
- A looping structure
- A VBA function : MsgBox