30.04.2017 Views

4523756273

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50<br />

Part II: How VBA Works with Excel<br />

Using the Editor tab<br />

Figure 3-5 shows the options accessed by clicking the Editor tab of the<br />

Options dialog box. Use the options in the Editor tab to control how certain<br />

things work in the VBE.<br />

Figure 3-5:<br />

This is the<br />

Editor tab in<br />

the Options<br />

dialog box.<br />

Auto Syntax Check option<br />

The Auto Syntax Check setting determines whether the VBE pops up a dialog<br />

box if it discovers a syntax error while you’re entering your VBA code. The<br />

dialog box tells roughly what the problem is. If you don’t choose this setting,<br />

VBE flags syntax errors by displaying them in a different color from the rest<br />

of the code, and you don’t have to deal with any dialog boxes popping up on<br />

your screen.<br />

I usually keep this setting turned off because I find the dialog boxes annoying<br />

and I can usually figure out what’s wrong with a statement. Before I was a<br />

VBA veteran, I found this assistance quite helpful.<br />

Require Variable Declaration option<br />

If the Require Variable Declaration option is set, VBE inserts the following<br />

statement at the beginning of each new VBA module you insert:<br />

Option Explicit<br />

Changing this setting affects only new modules, not existing modules. If this<br />

statement appears in your module, you must explicitly define each variable<br />

you use. In Chapter 7, I explain why you should develop this habit.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!