option explicit
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Option Explicit

Option Explicit

resolvedResolved · Low Priority · Version 2003

replyReply Thu 29 Jan 2009, 16:42Delegate Camilla said...

Camilla has attended:
Excel VBA Intro Intermediate course

Option Explicit

What is the purpose of the "Option Explicit" section at the top of the code editor page?

For upcoming training course dates see: Pricing & availability

replyReply Mon 2 Feb 2009, 10:19Trainer Carlos said...

RE: Option Explicit

Hi Camilla

By default, VBA doesn't require that you declare your variables using the Dim statement.

If the compiler encounters a name that it doesn't recognize as an existing variable, one of the VBA reserved words, or a property or method, it will create a new variable by that name.

While this may seem convenient, spelling mistakes can lead to bugs in the code that are difficult to find.

Using Option Explicit requires that all variables be declared.

The area where the Option Explicit appears is known as the Declarations area and it is where all Module level and public variables are written.

Hope this helps

Carlos

replyReply Tue 3 Feb 2009, 15:50Delegate Camilla said...

RE: Option Explicit

Great, thanks Carlos.

 

Please browse our web site to find out more about
excel-training-advanced courses and other Microsoft training courses.

Excel tip:

Convert Text into Number

Some times numbers maybe imported in as text or you maybe concatenating numbers that form a text string that now are treated, because you had to extract them by Text functions

To convert Text into Number just encase the relevant cell reference or formula in the TEXT function. See Converting American Date to European hint

eg TEXT(Ref) or TEXT(formula)

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard