ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stop on variable (https://www.excelbanter.com/excel-programming/318616-stop-variable.html)

Jos Vens[_2_]

Stop on variable
 
Hi,

does anyone know if it is possible to stop the VBA-code when it reaches (the
first) variable I have in mind.

eg. I am tracing for a variable when it changes from value but I don't know
anymore where it stands in my procedures, so I should like to ask excel to
stop whenever it encounters this specific variable (in stead of setting the
red dot in the margin or using the command Stop)

Thanks,
Jos Vens



Sharad

Stop on variable
 
Where you defined the variable, define it wrong type.

E.g. Define the variable as Boolean, if actually it will be a string. Or
define it as Range if it is not going to a range at all.

Remove any On Error commands in the code.

So when the variable is first reached to assining a value, or to check
its value, you will get error 'Type Mismatch' or 'Object Variable or
With Block variable not set'.


Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jos Vens[_2_]

Stop on variable
 
Sorry Sharad,

I was thinking of a tool embedded in the VBA environment like the window
Direct where you can put the name of a variable and then Excel stops when it
encounters it.

I'm not prepared to run through thousands of lines to see if the On Error is
set or not.

Thanks anyway,
Jos

"Sharad" schreef in bericht
...
Where you defined the variable, define it wrong type.

E.g. Define the variable as Boolean, if actually it will be a string. Or
define it as Range if it is not going to a range at all.

Remove any On Error commands in the code.

So when the variable is first reached to assining a value, or to check
its value, you will get error 'Type Mismatch' or 'Object Variable or
With Block variable not set'.


Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Dave Peterson[_5_]

Stop on variable
 
Inside the VBE:

Debug|Add watch

There's an option to "break when value changes"



Jos Vens wrote:

Hi,

does anyone know if it is possible to stop the VBA-code when it reaches (the
first) variable I have in mind.

eg. I am tracing for a variable when it changes from value but I don't know
anymore where it stands in my procedures, so I should like to ask excel to
stop whenever it encounters this specific variable (in stead of setting the
red dot in the margin or using the command Stop)

Thanks,
Jos Vens


--

Dave Peterson

Jos Vens[_2_]

Stop on variable
 
Thanks Dave,

it works perfect for tracing changing values of variables!

However, I also like to trace defined names like [myName]. If I add the
control to the window, it stops on every line of my code. Is this not
possible?

Jos


"Dave Peterson" schreef in bericht
...
Inside the VBE:

Debug|Add watch

There's an option to "break when value changes"



Jos Vens wrote:

Hi,

does anyone know if it is possible to stop the VBA-code when it reaches
(the
first) variable I have in mind.

eg. I am tracing for a variable when it changes from value but I don't
know
anymore where it stands in my procedures, so I should like to ask excel
to
stop whenever it encounters this specific variable (in stead of setting
the
red dot in the margin or using the command Stop)

Thanks,
Jos Vens


--

Dave Peterson




Dave Peterson[_5_]

Stop on variable
 
I couldn't do it.

I'm guessing that since the value in that range could change any time, VBA sees
it as something that might have changed. (But that's just a guess.)



Jos Vens wrote:

Thanks Dave,

it works perfect for tracing changing values of variables!

However, I also like to trace defined names like [myName]. If I add the
control to the window, it stops on every line of my code. Is this not
possible?

Jos

"Dave Peterson" schreef in bericht
...
Inside the VBE:

Debug|Add watch

There's an option to "break when value changes"



Jos Vens wrote:

Hi,

does anyone know if it is possible to stop the VBA-code when it reaches
(the
first) variable I have in mind.

eg. I am tracing for a variable when it changes from value but I don't
know
anymore where it stands in my procedures, so I should like to ask excel
to
stop whenever it encounters this specific variable (in stead of setting
the
red dot in the margin or using the command Stop)

Thanks,
Jos Vens


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 08:31 AM.

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