Stop on variable

  • Thread starter Thread starter Jos Vens
  • Start date Start date
J

Jos Vens

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
 
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
 
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
 
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
 
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 said:
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 said:
Inside the VBE:

Debug|Add watch

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