Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use modules so that values calculated in one of them can beused by another?
Basically i am trying to put all of subroutines which are under
thisworkbook section into different modules. for example if there are sub1,sub2,sub3 under thisworkbook code window such that sub0 call sub1 call sub2 endsub0 sub1 endsub1 sub2 end sub2 I want to write or move sub1 and sub2 into different modules such as into module1 and module 2 respectively: module1 sub1 end sub1 module2 sub1 end sub1 but the problem is when sub1 calculates and obtains a results and assigns it to a variable which will be used in sub2 it is already erased when module1 closes and module2 opens to call sub2. so the question is what can I do so that the values which are assigned to variables in a module are preserved or stick so they can be used by other subs in other modules? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use modules so that values calculated in one of them can be
read up on declaring variables and "scope"
Declare your variables at the top of the module and make them PUBLIC ... this makes them available not onlyt to procedures in the module, but to procedures in other modules. OPTION EXPLICIT PUBLIC MyVar as Variant PUBLIC MiLong as Long Sub mysub1() End sub "cagri mollamahmutoglu" wrote: Basically i am trying to put all of subroutines which are under thisworkbook section into different modules. for example if there are sub1,sub2,sub3 under thisworkbook code window such that sub0 call sub1 call sub2 endsub0 sub1 endsub1 sub2 end sub2 I want to write or move sub1 and sub2 into different modules such as into module1 and module 2 respectively: module1 sub1 end sub1 module2 sub1 end sub1 but the problem is when sub1 calculates and obtains a results and assigns it to a variable which will be used in sub2 it is already erased when module1 closes and module2 opens to call sub2. so the question is what can I do so that the values which are assigned to variables in a module are preserved or stick so they can be used by other subs in other modules? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
retaining variable values across modules | Excel Programming | |||
Calculated Values | Excel Worksheet Functions | |||
Loosing values when working on different functions and modules.. | Excel Programming | |||
There must be a way!!!--set cells' values equal to calculated values in another range | Excel Programming | |||
Exporting calculated values | Setting up and Configuration of Excel |