Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have some code that creates an array public variable and then saves some
values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you click the Reset button (or Run|reset in the menu), then the variables
will be reset. If you have End (not "end if", "end sub", "end select", ...), you'll be stopping the macro, but also reseting the variables. mcambrose wrote: I have some code that creates an array public variable and then saves some values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for taking the time to answer. I checked the variable at the last
statement prior to "end sub" and it is still there as expected. Once I execute "end sub" the variable is gone. In a subroutine in another workbook I also checked the variable before "end sub" and it is available as expected, however after I execute the "end sub" it is still available. Any idea how these two could be different? In both instances I checked just before the "end sub" and just after it. Thanks for any suggestions. "Dave Peterson" wrote: If you click the Reset button (or Run|reset in the menu), then the variables will be reset. If you have End (not "end if", "end sub", "end select", ...), you'll be stopping the macro, but also reseting the variables. mcambrose wrote: I have some code that creates an array public variable and then saves some values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Declare the variable outside any sub, then it doesn't get destroyed.
"mcambrose" wrote: Thanks for taking the time to answer. I checked the variable at the last statement prior to "end sub" and it is still there as expected. Once I execute "end sub" the variable is gone. In a subroutine in another workbook I also checked the variable before "end sub" and it is available as expected, however after I execute the "end sub" it is still available. Any idea how these two could be different? In both instances I checked just before the "end sub" and just after it. Thanks for any suggestions. "Dave Peterson" wrote: If you click the Reset button (or Run|reset in the menu), then the variables will be reset. If you have End (not "end if", "end sub", "end select", ...), you'll be stopping the macro, but also reseting the variables. mcambrose wrote: I have some code that creates an array public variable and then saves some values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. The variable that is being destroyed is declared as public at the top
of the module in both cases I describe. "Joel" wrote: Declare the variable outside any sub, then it doesn't get destroyed. "mcambrose" wrote: Thanks for taking the time to answer. I checked the variable at the last statement prior to "end sub" and it is still there as expected. Once I execute "end sub" the variable is gone. In a subroutine in another workbook I also checked the variable before "end sub" and it is available as expected, however after I execute the "end sub" it is still available. Any idea how these two could be different? In both instances I checked just before the "end sub" and just after it. Thanks for any suggestions. "Dave Peterson" wrote: If you click the Reset button (or Run|reset in the menu), then the variables will be reset. If you have End (not "end if", "end sub", "end select", ...), you'll be stopping the macro, but also reseting the variables. mcambrose wrote: I have some code that creates an array public variable and then saves some values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you need to pass data betwen uerforms create a text box on the userform
and make the textbox Visible parameter False. Then use the Text box as a parameter list to pass data between userforms. I had your problem beofre an that is how I solved the problem. If you have an array use the Join and split functions save and recal an arran of data to/from a string. "mcambrose" wrote: Thanks. The variable that is being destroyed is declared as public at the top of the module in both cases I describe. "Joel" wrote: Declare the variable outside any sub, then it doesn't get destroyed. "mcambrose" wrote: Thanks for taking the time to answer. I checked the variable at the last statement prior to "end sub" and it is still there as expected. Once I execute "end sub" the variable is gone. In a subroutine in another workbook I also checked the variable before "end sub" and it is available as expected, however after I execute the "end sub" it is still available. Any idea how these two could be different? In both instances I checked just before the "end sub" and just after it. Thanks for any suggestions. "Dave Peterson" wrote: If you click the Reset button (or Run|reset in the menu), then the variables will be reset. If you have End (not "end if", "end sub", "end select", ...), you'll be stopping the macro, but also reseting the variables. mcambrose wrote: I have some code that creates an array public variable and then saves some values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't have a guess.
Can you skinny down the code so that it only shows the problem and post it? mcambrose wrote: Thanks for taking the time to answer. I checked the variable at the last statement prior to "end sub" and it is still there as expected. Once I execute "end sub" the variable is gone. In a subroutine in another workbook I also checked the variable before "end sub" and it is available as expected, however after I execute the "end sub" it is still available. Any idea how these two could be different? In both instances I checked just before the "end sub" and just after it. Thanks for any suggestions. "Dave Peterson" wrote: If you click the Reset button (or Run|reset in the menu), then the variables will be reset. If you have End (not "end if", "end sub", "end select", ...), you'll be stopping the macro, but also reseting the variables. mcambrose wrote: I have some code that creates an array public variable and then saves some values to this variable. When I end this subroutine, I can look at the immediate window and check the contents and it is available. I have another subroutine that uses the same code, but it also has a userform in it. When the second routine finishes, the variable contents are destroyed. Is there something about userforms that messes with variables. -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Variables being randomly destroyed | Excel Programming | |||
Global variable destroyed when form closed | Excel Programming | |||
Variable Determines Number of Cell in Formula Range | Excel Worksheet Functions | |||
drop down selection determines other drop down content | Excel Discussion (Misc queries) | |||
Cell/Variable content substitution | Excel Programming |