#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 92
Default Access to Variable

Here's a very basic question that I'm embarassed to ask, but nothing
ventured, nothing gained.
The cause of my problem stems from the lack of understanding the whole
archectecture of environments.
I create a procedure and it seems as though I have no control of where it
goes. Sometimes they get nestled together, separated by a simple line and
othertimes I have to go back to the menu and specifically select the next
module.
More important, is that when I create and fill a variable in one routine,
even if it is declared (by default) as a Public, I cannot seem to use it in
the next routine.

Can someone direct me to a good place to start looking to get a better
understanding of this subject matter.

Thanks in advance,
Craig


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Access to Variable

You might start by reading the responses to this discussion:
http://www.microsoft.com/office/comm...304&sloc=en-us

Just to give you a kick-start, there are 4 places in an Excel workbook that
code can be located:
#1 - code modules not associated with the workbook/worksheets (can be
referenced from more specific code areas)
#2 - code associated with the workbook events
#3 - code associated with woksheet events (one for each worksheet)
#4 - code associated with UserForms

A Public variable/constant to be accessed from anywhere at all must be
declared in one of the #1 type code modules and it must be declared outside
of a Sub or Function. So those Public values would be at the very beginning
of the module, before any Sub or Function code in it.

If you declare a variable/constant with the same name as a Public one, then
the one declared within the Sub/Function will be used instead of the Public
one. This is all about 'scope'. So you may want to focus on that subject in
your initial reading.

Good luck.

"C Brandt" wrote:

Here's a very basic question that I'm embarassed to ask, but nothing
ventured, nothing gained.
The cause of my problem stems from the lack of understanding the whole
archectecture of environments.
I create a procedure and it seems as though I have no control of where it
goes. Sometimes they get nestled together, separated by a simple line and
othertimes I have to go back to the menu and specifically select the next
module.
More important, is that when I create and fill a variable in one routine,
even if it is declared (by default) as a Public, I cannot seem to use it in
the next routine.

Can someone direct me to a good place to start looking to get a better
understanding of this subject matter.

Thanks in advance,
Craig



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
Import into Access from Excel, passing a variable for the field... [email protected] Excel Worksheet Functions 1 April 12th 07 09:44 AM
Transpose a variable length list into Excel / Access Table Pete New Users to Excel 11 September 13th 06 07:37 PM
Trying to access different files depening on a variable Priorsyeat Excel Discussion (Misc queries) 1 April 6th 06 01:13 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


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

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

About Us

"It's about Microsoft Excel"