#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Variables

I have a spreadsheet with 2 buttons on it, and all the code behind the
sheet

I'd prefer it if one particular variable (an array) was "held" at the
end of running button1, before I press button2.

I can use a DoEvents loop so effectively the program stays running, but
I was wondering if there was a better way. It's not a major problem for
me, it just means I'm doing a load of processing I don't really need to
do had the variable still been in memory
--
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Variables

"Mike NG" wrote in message
...
I have a spreadsheet with 2 buttons on it, and all the code behind the
sheet

I'd prefer it if one particular variable (an array) was "held" at the end
of running button1, before I press button2.

I can use a DoEvents loop so effectively the program stays running, but I
was wondering if there was a better way. It's not a major problem for me,
it just means I'm doing a load of processing I don't really need to do had
the variable still been in memory


Hi Mike,

If you declare your variable in the declarations section at the top of
the code module outside of any specific procedure that variable will hold
its value between button clicks.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Variables

On Thu, 2 Jun 2005 at 12:23:28, Rob Bovey (Rob Bovey
) wrote:
Hi Mike,

If you declare your variable in the declarations section at the top of
the code module outside of any specific procedure that variable will hold
its value between button clicks.

Sorry me being stupid. I was already doing this, but I guessed some
sort of unexpected end of execution must have happened, cos last time I
debugged this it didn't seem to be happening
--
Mike
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Variables

Did you click the Reset button (in the VBE)?

Do you have any lines of code with just End on them--not "end sub", "end if",
"end function"--just plain old End?

Either of those will reset those variables.

Mike NG wrote:

On Thu, 2 Jun 2005 at 12:23:28, Rob Bovey (Rob Bovey
) wrote:
Hi Mike,

If you declare your variable in the declarations section at the top of
the code module outside of any specific procedure that variable will hold
its value between button clicks.

Sorry me being stupid. I was already doing this, but I guessed some
sort of unexpected end of execution must have happened, cos last time I
debugged this it didn't seem to be happening
--
Mike


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Variables

On Fri, 3 Jun 2005 at 08:51:03, Dave Peterson (Dave Peterson
) wrote:

Do you have any lines of code with just End on them--not "end sub", "end if",
"end function"--just plain old End?

You've hit the nail on the head there -

I've looked at the help for "End" and will consider using "Stop"
instead. Glad I wasn't going insane

Either of those will reset those variables.


--
Mike


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Variables

I don't think you'll want to use Stop--it's used when you're developing your
code. It's gonna try to sit there waiting for you to continue. (Kind of like a
breakpoint in the VBE.)

Usually, you can wrap your code around some sort of If statement (or Do or any
type of conditional statement).



Mike NG wrote:

On Fri, 3 Jun 2005 at 08:51:03, Dave Peterson (Dave Peterson
) wrote:

Do you have any lines of code with just End on them--not "end sub", "end if",
"end function"--just plain old End?

You've hit the nail on the head there -

I've looked at the help for "End" and will consider using "Stop"
instead. Glad I wasn't going insane

Either of those will reset those variables.


--
Mike


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Variables

On Fri, 3 Jun 2005 at 17:27:51, Dave Peterson (Dave Peterson
) wrote:
I don't think you'll want to use Stop--it's used when you're developing your
code. It's gonna try to sit there waiting for you to continue. (Kind of like a
breakpoint in the VBE.)

Usually, you can wrap your code around some sort of If statement (or Do or any
type of conditional statement).

Yeah I did notice the code still running when I tried to exit the
debugger. As I'm only in the development stages, the scenarios where I
am using "End" are probably critical errors where I need button1 to be
pressed after corrections made. I can also control whether buttons are
enabled or disabled so I should know the status of everything
--
Mike
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Variables

On Thu, 2 Jun 2005 at 19:59:41, Mike NG (Mike NG
) wrote:
I have a spreadsheet with 2 buttons on it, and all the code behind the
sheet

I'd prefer it if one particular variable (an array) was "held" at the
end of running button1, before I press button2.

I can use a DoEvents loop so effectively the program stays running, but
I was wondering if there was a better way. It's not a major problem
for me, it just means I'm doing a load of processing I don't really
need to do had the variable still been in memory

After more investigation I know what "problem" I was having

After button1 had finished, I was using Alt-F11 Control-G to display the
array variable which was coming back "sub or function not defined".
However if I put a breakpoint right at the top of button2 and display it
there, it's OK
--
Mike
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
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
More than 1 Variables [email protected] Excel Discussion (Misc queries) 1 November 29th 06 02:09 AM
Too many variables? elite Excel Worksheet Functions 2 May 19th 06 10:26 PM
Variables Chip Pearson Excel Programming 0 July 9th 04 04:22 PM
Variables No Name Excel Programming 2 July 9th 04 05:37 AM


All times are GMT +1. The time now is 01:19 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"