Option Explicit

To avoid the problem described in the previous example, we need a way to make Excel refuse to run a program if it contains any variables that we have not explicitly declared. This is done simply by placing the line:

Option Explicit in the Declarations section of each code module. Since it is easy to forget to do this, VBA provides an option called "Require Variable Declaration" in its Options dialog box. When this option is selected, VBA automatically inserts the Option Explicit line for us. Therefore, I strongly recommend that you enable this option.

Now let us briefly discuss some of the data types in Table 5-1.

0 0

Post a comment