Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
option explicit
Hi,
Two quick questions about 'option explicit.' 1) What does it do? 2) How do I configure VBE to automatically set option explicit? I know it has something to do with declaring variables, but I don't know why it's important. Thanks, Dave -- Brevity is the soul of wit. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
option explicit
Option explicit forces the user to declare variables before the variable can
be used. In the VB Editor (Alt + F11) click TOOLS in the menu and select OPTIONS. Click the EDITOR tab and then click the REQUIRE VARIABLE DECLARATION check box to turn OPTION EXPLICIT on. -- Kevin Backmann "Dave F" wrote: Hi, Two quick questions about 'option explicit.' 1) What does it do? 2) How do I configure VBE to automatically set option explicit? I know it has something to do with declaring variables, but I don't know why it's important. Thanks, Dave -- Brevity is the soul of wit. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
option explicit
And an example of why it's important.
Ctr_1 = Ctr_l + 1 looks like it should update ctr_1. But the right hand side uses ctr_L (ell, not one). So if you had forced yourself to delclare your variables with "Option Explicit", it might be moments of debugging time instead of hours. And one more reason I like it is that when I declare an object explicitly: Dim Wks as worksheet I get VBA's intellisense to help out when I'm writing the code. wks. As soon as I hit that dot, I get a list of properties and methods that could come next. And one more reason. If I declare a variable like: dim myWksThatShowsTheSummary as Worksheet I can type mywks and hit ctrl space bar to have the VBE autocomplete (or show me possible matches) that variable. And I know that when I finish coding that statement, the VBE will match my upper/lower case in the Dim statement. If the variable stays lower case, I know I made a typo. Dave F wrote: Hi, Two quick questions about 'option explicit.' 1) What does it do? 2) How do I configure VBE to automatically set option explicit? I know it has something to do with declaring variables, but I don't know why it's important. Thanks, Dave -- Brevity is the soul of wit. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checkboxes vs. Option Buttons | Excel Discussion (Misc queries) | |||
the option "sent to" mail recipient is not available in excel 200 | Excel Discussion (Misc queries) | |||
Excel instance used with "Export to Microsoft Excel" option in Internet Explorer | Excel Discussion (Misc queries) | |||
Second option button disappears when I make another column | Excel Worksheet Functions | |||
Filter option | Excel Discussion (Misc queries) |