Using the Editor tab

Figure 7-6 shows the options that you access by clicking the Editor tab of the Options dialog box.

Options totof Formal Gwwml Dockna

iod? Sertirgs □ auto inte* cnecfc IVIleore HjnisitDiilefihofi

ListMefiOefs @ 4uto QuckLnh 0 Autf> Dflla Tp?

bíl S'ss-end-O'cc Tex;id&ng 0 & Flí vie ■■

0 Sewrstof

Figure 7-6: The Editor tab of the Options dialog box.


The Auto Syntax Check setting determines whether the VBE pops up a dialog box if it discovers a syntax error while you're entering your VBA code. The dialog box tells you roughly what the problem is. If you don't choose this setting, VBE flags syntax errors by displaying them in a different color from the rest of the code, and you don't have to deal with any dialog boxes popping up on your screen.

I keep this setting turned off because I find the dialog boxes annoying, and I can usually figure out what's wrong with an instruction. But if you're new to VBA, you might find this assistance helpful.


If the Require Variable Declaration option is set, VBE inserts the following statement at the beginning of each new VBA module that you insert:

Option Explicit

If this statement appears in your module, you must explicitly define each variable that you use. This is an excellent habit to get into, although it does require some additional effort on your part. If you don't declare your variables, they will all be of the Variant data type, which is flexible but not efficient in terms of storage or speed. I discuss variable declaration in more depth in Chapter 8.

Note Changing the Require Variable Declaration option affects only new modules, not existing modules.


If the Auto List Members option is set, VBE provides some help when you're entering your VBA code by displaying a list of member items for an object. These items include methods and properties for the object that you typed.

This option is very helpful, and I always keep it turned on. Figure 7-7 shows an example of Auto List Members (which will make a lot more sense when you actually start writing VBA code). In this example, VBE is displaying a list of members for the Application object. You can just select an item from the list and press Tab, thus avoiding typing it (or, double-click an item). Using the Auto List Members list also ensures that the item is spelled correctly.

T^tteuk* IMtfiníriii

»«•Mh v TIM



tifl ftb Un-;'Ttt(rtj * zD iilKWiM pfl Uih-.mivfit r9 Vll^Tl tfi Ut^tmnBipJWM of ;»u* át .HI



2 t!


Figure 7-7: An example of Auto List Members.

Figure 7-7: An example of Auto List Members.


If the Auto Quick Info option is set, the VBE displays information about the arguments available for functions, properties, and methods while you type. This can be very helpful, and I always leave this setting on. Figure 7-8 shows this feature in action. It's displaying the syntax for the Cells property.


Ml M(.rf„l,l ltv.i.1

- PX?

I límuq v


_0«i,r|fl»*«»i!»<i ;■■ ■ ■-■- -■-■ ■




Figure 7-8: An example of Auto Quick Info offering help about the Cells property.

Figure 7-8: An example of Auto Quick Info offering help about the Cells property.


If the Auto Data Tips option is set, you can hover your mouse pointer over a variable, and VBE displays the value of the variable. This technique works only when the procedure is paused while debugging. When you enter the wonderful world of debugging, you'll definitely appreciate this option. I always keep this option turned on. AUTO INDENT OPTION

The Auto Indent setting determines whether VBE automatically indents each new line of code by the same amount as the previous line. I'm a big fan of using indentations in my code, so I keep this option on. You can also specify the number of characters to indent; the default is four.

Tip Use the Tab key, not the space bar, to indent your code. Using the Tab key results in more consistent spacing. In addition, you can use Shift+Tab to unindent a line of code. These keys also work if you select more than one statement.


The Drag-and-Drop Text Editing option, when enabled, lets you copy and move text by dragging and dropping. I keep this option turned on, but I never use drag-and-drop editing. I prefer to use keyboard shortcuts for copying and pasting.


The Default to Full Module View option specifies how procedures are viewed. If this option is set, procedures in the code window appear as a single scrollable window. If this option is turned off, you can see only one procedure at a time. I keep this setting turned on.


When the Procedure Separator option is turned on, the VBE displays separator bars between procedures in a code window (assuming that the Default to Full Module View option is also selected). I like the visual cues that show where my procedures end, so I keep this option turned on.

0 0

Post a comment