Page 112 - Excel Progamming Weekend Crash Course
P. 112
h540629 ch07.qxd 9/2/03 9:33 AM Page 87
SESSION
7
Procedures and Modules
Session Checklist
✔ Defining sub and function procedures
✔ Specifying procedure arguments
✔ Using optional and ParamArray arguments
✔ Calling procedures
✔ Declaring variables in procedures
✔ Procedure scope
✔ Storing and organizing procedures
ou learned in a previous session that the procedure is VBA’s fundamental unit of code
organization. If you record a macro, it is saved as a VBA procedure. Furthermore, the
Y simplest VBA programs consist of a single procedure. More complex programs, on the
other hand, consist of many interacting procedures, and you must know how to create and
work with procedures to create Excel programs.
Session 2 explains how procedures are used to organize VBA code.
Cross-Ref
There are five different types of procedures in VBA:
A sub procedure is a named, independent section of code.
A function procedure is similar to a sub procedure with the added feature of returning
data to the program that called it.
A method is a procedure (either sub or function) within a class module.