ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Values of Variable after Project has Run (https://www.excelbanter.com/excel-programming/381452-values-variable-after-project-has-run.html)

Tim Childs

Values of Variable after Project has Run
 
Hi

Is it possible to check the values of all the public variables after the
subs have run. These are public and module declared variables. As I
understand it, the Locals window is not of any help

I can think of way of "cobbling" something together but wondered if anyone
has something almost "ready to go"

I realise the procedure may need to be called for each variable.

Thanks

Tim



Chip Pearson

Values of Variable after Project has Run
 
You can add a "Watch" on public variable. You have to set up each Watch
individually -- you can't say "Watch All Globals"

Suppose you have code like

Public Y As Long
Public X As Long

Sub AAA()
X = 123
Y = 321
End Sub

Sub BBB()
X = 333
Y = 444
End Sub

In VBA, go to the Debug menu, choose "Add Watch", enter the variable name in
the "Expression" box, choose "(All Procedures)" in the Procedure box, choose
"(All Modules)" in the modules dropdown, and choose "Watch Expression" in
the Watch Type frame. Repeat this procedure for each variable you want to
watch. It will show you the value of the variables even after a procedure is
finished.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Tim Childs" wrote in message
...
Hi

Is it possible to check the values of all the public variables after the
subs have run. These are public and module declared variables. As I
understand it, the Locals window is not of any help

I can think of way of "cobbling" something together but wondered if anyone
has something almost "ready to go"

I realise the procedure may need to be called for each variable.

Thanks

Tim





Tim Childs

Values of Variable after Project has Run
 
Hi Chip, Tom

Many thanks for those solutions

Tim


"Tom Ogilvy" wrote in message
...
assume you have a public variable name

MyVar

make the immediate window visible (and the project with the variable the
active project) and in the immediate window do

? MyVar

--
Regards,
Tom Ogilvy


"Tim Childs" wrote:

Hi

Is it possible to check the values of all the public variables after the
subs have run. These are public and module declared variables. As I
understand it, the Locals window is not of any help

I can think of way of "cobbling" something together but wondered if

anyone
has something almost "ready to go"

I realise the procedure may need to be called for each variable.

Thanks

Tim







All times are GMT +1. The time now is 12:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com