ABSTRACT

A program is a list of instructions to the computer. The point is to make the computer perform a task. To avoid chaos, a program needs to have a certain structure. The computer cannot execute the instructions in random order, as this will lead to an unpredictable result. In VBA the list of instructions is put within the context of a procedure, or subroutine as it is called in VBA. A procedure consists of a list of instructions. Each instruction is called a statement, and is usually written on a new line. The computer will execute the statements in sequential order, starting at the top. Later in this book we will see that the order of execution can be changed by the use of control structures. The structure of a subroutine is shown below: Sub Name()  Statement1  Statement2  …  StatementN End Sub