Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Question re Workbook level declarations

Hello,
Trying to meet deadline but couldn't find anything in MS documentation re
making variable declarations at the Workbook level under ThisWorkbook. If I
make such a variable declaration there with Option Explicit and Public, will
it be available to all Worksheets and modules code? I created a boolean such
var and one worksheet code module recognized it but another cried "Variable
Not Defined".
I was trying to avoid putting it into a code module if possible.
Thanks, God bless
Van
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Question re Workbook level declarations

Hi VanS,

Worksheet and ThisWorkbook module are private, thus the message regarding
the variable in the other code module.

To make a variable global, place it in a standard module, outside any
procedures. This is usually done in a MGlobals module (if you use one), at
the top in the Declarations section. Declaring it Public makes it accessible
to all components of your project while the project is open.

HTH
Regards,
GS

"VanS" wrote:

Hello,
Trying to meet deadline but couldn't find anything in MS documentation re
making variable declarations at the Workbook level under ThisWorkbook. If I
make such a variable declaration there with Option Explicit and Public, will
it be available to all Worksheets and modules code? I created a boolean such
var and one worksheet code module recognized it but another cried "Variable
Not Defined".
I was trying to avoid putting it into a code module if possible.
Thanks, God bless
Van

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question re Workbook level declarations


you should be ok to create a public variable in any module. If you have
to use them place them straight after the option explicit eg:

Option Explicit

Public blnVar As Boolean

Don't place them inside a subroutine.

Personally I avoid them like the plague. They make debuging a piece of
code fraught with difficulties. If I do I create a code module called
Globals so that they are clearly obvious to everyone. But my preferred
method is to create a class module to hold global values as properties.


regards


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=521408

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Provide option to specify level of difficulty of the Question dhstein Excel Discussion (Misc queries) 2 April 3rd 09 03:07 PM
Workbook level recalculation Lavneet Singh Excel Programming 3 November 21st 05 05:52 PM
Declarations Procedure and Duplicate Declarations Neal Zimm Excel Programming 3 May 31st 05 01:01 AM
Application Level Events Question nickg420[_4_] Excel Programming 3 July 16th 04 05:02 PM
Why, when I create workbook-level name does it jump it to Sheet-level ? Charles Jordan Excel Programming 1 November 5th 03 08:43 PM


All times are GMT +1. The time now is 05:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"