How do I watch a variable change value during Visual Basic Code e.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I watch a variable in an excel macro change value as the visual basic
code is running? The variable changes value every 30 seconds or so and I want
to monitor progress of the execution by looking at the value without stopping
the run.
 
Hi

One way is to add a line after the variable changes which would show the
message box displaying the new variable value:

MsgBox MyVariable

Once you know everything is working correctly remember to remove the line
from your code.

Regards

Paul
 
Stewart,

Watch needs an interrupt to output the details. So, single-stepping, or
break points will provide such an interrupt, but otherwise I think you are
stymied.

You could add an Ontime call for every 30 seconds and do a Debug.Print of
that variable (but you will need to make it global, not procedure variable).

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
After the line where the code changes the variable's value add this:

Application.Statusbar = variablename


Patrick Molloy
Microsoft Excel MVP
 
Thanks, that was very helpful, especially once I found the statusbar.

Is there a way to display this on the VBE editor screen? When the workbook
is displayed there is a lot of activity on the worksheets - numbers flying
everywhere,
and I like to cover this by expanding the VBE editor screen to full size,
but it covers the
status bar. I tried balloons, msgbox, textbox, etc but none of those had a
display only feature, they always waited for an event before execution would
continue.
 
in the code add:

Debug.Print variablename

Stewart1234 said:
Thanks, that was very helpful, especially once I found the statusbar.

Is there a way to display this on the VBE editor screen? When the workbook
is displayed there is a lot of activity on the worksheets - numbers flying
everywhere,
and I like to cover this by expanding the VBE editor screen to full size,
but it covers the
status bar. I tried balloons, msgbox, textbox, etc but none of those had a
display only feature, they always waited for an event before execution would
continue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top