![]() |
Question What determines if publlic variable content is destroyed
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. |
Question What determines if publlic variable content is destroyed
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 |
Question What determines if publlic variable content is destro
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 |
Question What determines if publlic variable content is destro
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 |
Question What determines if publlic variable content is destro
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 |
Question What determines if publlic variable content is destro
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 |
Question What determines if publlic variable content is destro
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 |
All times are GMT +1. The time now is 12:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com