#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxes vs. Option Buttons JW_4222 Excel Discussion (Misc queries) 2 February 1st 06 01:38 PM
the option "sent to" mail recipient is not available in excel 200 Ngozi Excel Discussion (Misc queries) 1 August 23rd 05 02:50 PM
Excel instance used with "Export to Microsoft Excel" option in Internet Explorer Karl Schweitzer Excel Discussion (Misc queries) 0 April 7th 05 06:17 PM
Second option button disappears when I make another column Monique Excel Worksheet Functions 0 March 9th 05 09:57 PM
Filter option vishu Excel Discussion (Misc queries) 1 February 28th 05 01:36 PM


All times are GMT +1. The time now is 08:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"