ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Forcing Dim Requirement (https://www.excelbanter.com/excel-programming/356356-forcing-dim-requirement.html)

Phil_V[_7_]

Forcing Dim Requirement
 

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

Thanks,

Phi

--
Phil_
-----------------------------------------------------------------------
Phil_V's Profile: http://www.excelforum.com/member.php...fo&userid=3185
View this thread: http://www.excelforum.com/showthread.php?threadid=52371


kwiklearner[_10_]

Forcing Dim Requirement
 

type "option explicit" prior to sub

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

Thanks,

Phi


--
kwiklearne
-----------------------------------------------------------------------
kwiklearner's Profile: http://www.excelforum.com/member.php...fo&userid=3190
View this thread: http://www.excelforum.com/showthread.php?threadid=52371


Jim Thomlinson

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



Chip Pearson

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"
wrote in message
...

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





All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com