option explicit

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

Option Explicit

resolvedResolved · Low Priority · Version 2003

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?

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

RE: Option Explicit

Great, thanks Carlos.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Repeating headings on spreadsheets that print on more than one page

By default when you print a spreadsheet out and it prints on more than one page, the headings at the top and the side of the spreadsheet don't appear on all the pages following page 1.

To get Excel to repeat headings on all pages when printing, go to File - Page Setup - Sheet, then select the rows to repeat at the top of pages, and the columns to repeat at the side of pages by clicking on the red arrows at the right side of the two boxes under the 'Print titles' area. Then click OK.

If you view your spreadsheet in Print Preview, you should see the headings being repeated on each page.

View all Excel hints and tips


Server loaded in 0.08 secs.