![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
Can anyone help explain what does Option Explicit means and what does it do in a macro? (kinda redundant, I know, since the topic is self-explanatory)
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
From the VBA help files, explains it quite neatly really and should always be your first port of call: -
Used at module level to force explicit declaration of all variables in that module. Syntax Option Explicit Remarks If used, the Option Explicit statement must appear in a module before any procedures. When Option Explicit appears in a module, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements. If you attempt to use an undeclared variable name, an error occurs at compile time. If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement. Note Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear. |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
Sorry about that. But my computer at work doesn't have the VBA help files installed. And I am not sure if the IT people would want me to install it.
Is there an online source where I can look all of this up? |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
It forces variable definitions. This helps when you use variables to hold and insert or exchange data or controls with in code. This form allows for a clear scope of use when variable usage is complicated or could become unclear. Its use also helps keep frequently used variables from being miss-typed. Helps keep variables from being assigned a variant type if not defined with a Def statement. The down side is it can only be used in a true module.
The skinny on it is: It forces explicit variable declaration. Hope this helps. JSW |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
Oh, no, I wasn't having a go at you
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
It would probably be easier to go and ask your IT people to install it or install it yourself if your system does that "install on first use" thingy.
If they say "no" demand a reason. If the reason is insufficient give them so many lefts that they'll be begging for a right. Verbal abuse doesn't seem to have much effect on IT people (ours have built up a tolerance to it), stick to the violence. HTH |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
MudFace,
Don''t worry about it. I just was apologizing for not being able to find things on my own and bothering gooe people like you and the others who have responded to this with a question, I should be able to answer on my own. Anyway, Here's a link I found that might be useful. http://msdn.microsoft.com/library/de...hanges2000.asp |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|