VBA – Decisions if statement

Decision making allows the programmers to control the execution flow of a script or one of its sections. The execution is governed by one or more conditional statements.

Following is the general form of a typical decision making structure found in most of the programming languages.

Decision making statements in VBA

VBA provides the following types of decision making statements. Click the following links to check their details.

S.No. Statement & Description
1 if statementAn if statement consists of a Boolean expression followed by one or more statements.
2 if..else statementAn if else statement consists of a Boolean expression followed by one or more statements. If the condition is True, the statements under If statements are executed. If the condition is false, the Else part of the script is executed.
3 if…elseif..else statementAn if statement followed by one or more ElseIf statements, that consists of Boolean expressions and then followed by an optional else statement, which executes when all the condition become false.
4 nested if statementsAn if or elseif statement inside another if or elseif statement(s).
5 switch statementA switch statement allows a variable to be tested for equality against a list of values.

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