Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Variables being randomly destroyed Bill Schanks Excel Programming 3 February 26th 08 07:21 PM
Global variable destroyed when form closed [email protected] Excel Programming 2 August 25th 06 11:57 AM
Variable Determines Number of Cell in Formula Range MJSlattery Excel Worksheet Functions 0 March 30th 06 01:28 AM
drop down selection determines other drop down content lskelton Excel Discussion (Misc queries) 1 November 1st 05 11:14 PM
Cell/Variable content substitution Jim[_41_] Excel Programming 2 February 6th 04 07:13 PM


All times are GMT +1. The time now is 01:54 AM.

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"