Skip to main content

With...End With

The With...End With construct cannot be called a control statement because it does not modify code execution. It does, however, provide a handy shorthand that simplifies writing code in certain situations.

If...Then Statement

The If...Then statement, or If statement for short, is used in a program to execute a block of code if a specified logical condition is True.  If condition is True, the statements in the block (indicated by block1) are executed. If condition is False, they are not executed.

For...Next Statement

The For...Next statement repeats a block of code a specified number of times.

  • Index is a variable that is used to count loop repetitions. It is usually declared to be type Integer.
  • Start is an expression specifying the starting value of index.
  • Stop is an expression specifying the ending value of index.

Optionally, For...Next can use an increment value other than 1.

Comments

A comment is text in a VBA program that is ignored and has no effect on the program operation. You can (and should) use comments to document how the code works, provide details about procedure arguments, and add reminders to yourself or another programmer.

Comparison Operators

The comparison operators are used to perform comparisons between expressions. A comparison expression is actually a logical expression, evaluating to True or False depending on the data and operator used.

= Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to