+ Reply to Thread
Results 1 to 4 of 4

Forcing Dim Requirement

  1. #1
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Question Forcing Dim Requirement

    How do I set the option in Excel VBA that I MUST Dim variable before using them? I would prefer it this way to the default where Excel just 'creates' variables that are spelt differently etc.

    Thanks,

    Phil

  2. #2
    Registered User
    Join Date
    02-24-2006
    Posts
    24
    type "option explicit" prior to sub

    Quote Originally Posted by Phil_V
    How do I set the option in Excel VBA that I MUST Dim variable before using them? I would prefer it this way to the default where Excel just 'creates' variables that are spelt differently etc.

    Thanks,

    Phil

  3. #3
    Jim Thomlinson
    Guest

    RE: Forcing Dim Requirement

    Check out this link...

    http://www.cpearson.com/excel/DeclaringVariables.htm
    --
    HTH...

    Jim Thomlinson


    "Phil_V" wrote:

    >
    > How do I set the option in Excel VBA that I MUST Dim variable before
    > using them? I would prefer it this way to the default where Excel just
    > 'creates' variables that are spelt differently etc.
    >
    > Thanks,
    >
    > Phil
    >
    >
    > --
    > Phil_V
    > ------------------------------------------------------------------------
    > Phil_V's Profile: http://www.excelforum.com/member.php...o&userid=31857
    > View this thread: http://www.excelforum.com/showthread...hreadid=523711
    >
    >


  4. #4
    Chip Pearson
    Guest

    Re: Forcing Dim Requirement

    Put Option Explicit as the very first line in your code
    module(s), before and outside of any procedure declaration.

    You can have this automatically placed in new modules. In VBA go
    to the Tools menu, choose Options, then the Editor tab. There,
    place a check next to "Require Variable Declaration".


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Phil_V" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > How do I set the option in Excel VBA that I MUST Dim variable
    > before
    > using them? I would prefer it this way to the default where
    > Excel just
    > 'creates' variables that are spelt differently etc.
    >
    > Thanks,
    >
    > Phil
    >
    >
    > --
    > Phil_V
    > ------------------------------------------------------------------------
    > Phil_V's Profile:
    > http://www.excelforum.com/member.php...o&userid=31857
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=523711
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1