• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

II. The VBA Programming Language > 8. Control Statements

Chapter 8. Control Statements

We conclude our discussion of the VBA language with a discussion of the main VBA control statements , which are statements that affect the flow of control (or flow of execution) in a program.

The If...Then Statement

The If...Then statement is used for conditional control. The syntax is:

If Condition Then
   ' statements go here . . .
ElseIf AnotherCondition Then
   ' more statements go here . . .
Else
   ' more statements go here . . .
End If

Note that we may include more than one

ElseIf part and that both the ElseIf part(s) and the Else part are optional. We can also squeeze all parts of this statement onto a single line, which is generally only a good idea when the


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint