Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default 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!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default 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!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
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
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
How do I stop other circles in other cells to stop selecting? stauff Excel Worksheet Functions 2 October 29th 04 09:02 PM
How do I stop other circles in other boxes to stop selecting? stauff Excel Worksheet Functions 1 October 28th 04 10:27 PM
Macro: With Stop it works. Without Stop it doesn't. Don Wiss Excel Programming 2 October 12th 04 10:49 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 11:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"