View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] inews@questuscorp.com is offline
external usenet poster
 
Posts: 16
Default Option Explicit set at Application Level by Excel Add-in?

I understand your point Jon and it makes sense.

Horses for courses I guess. I can type 60WPM @ 99% accuracy. I type
code slower than that and rarely mistype things. I find
experimentation easier without Option Explicit. That's my experience.
Who knows, maybe I'm fooling myself... doesn't really matter.

Any ideas on why I might be getting those errors when not using Option
Explicit? It still seems mighty peculiar.

Jon Peltier wrote:
"don't want to have to dim every variable as I introduce or delete it as it
takes longer to finish playing about with it"

And you don't find that it's too easy to mistype a variable name and get
unexpected results, if the lack of Option Explicit allows you to use an
undeclared variable?

For example, this sub will produce a message box with a value of zero rather
than ten, and it may take minutes to notice the misspelling.

Sub TestRange
Set MyRange = ActiveSheet.Range("A1:A10")
MsgBox MyRnage.Rows.Count
End Sub

This type of problem is eliminated if Option Explicit is used, as it will
detect the misspelled variable when the sub is compiled or first run.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
oups.com...
Thanks Nick. Yep, it's not caused by that option as it isn't selected.

6 lines of code, 2 variables, acceptable time for completion. Simple
stuff. No burning need to dim those, other than this weird behaviour.
Also it's just slopping around with some test code before using it in
the real thing (it gets dimmed there), and don't want to have to dim
every variable as I introduce or delete it as it takes longer to finish
playing about with it.

You're right though, the need to not use Option Explicit is relatively
marginal.

Am mostly looking to solve the mystery or to discover if my Excel
installation is doing things that it shouldn't do.

NickHK wrote:
Yes, Option Explicit is module level. However, I have never heard of a
good
reason not to use it.

There is the setting ToolsOptionsEditorRequire Variable Declaration,
which will add "Option Explicit" to all subsequently created modules, but
not existing ones.

NickHK