19  Procedures

19.1 Types of procedure

Large programs can be complex and hard to understand and debug. To reduce the complexity we need to split the problem at hand into smaller subproblems, and then solve these without having to be distracted by the overall solution. For this purpose we use procedures. A procedure is defined as a named group of statements, and it can be run as a unit. To run the procedure we write the name of the procedure in the code. This is called a procedure call.

There are two types of procedure in VBA. Subroutine procedures are suited for solving a variety of tasks, while function procedures are more suitable for solving a problem that gives a value as the result.

Splitting a program into procedures has a lot of advantages: ...

Get Financial Modelling and Asset Valuation with Excel now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.