![]() |
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 |
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 |
All times are GMT +1. The time now is 02:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com