Syntax to stop code in Watch Window

  • Thread starter Thread starter EagleOne
  • Start date Start date
E

EagleOne

2003/2007

What is the correct Watch Window syntax to halt code processing?

I want to have the code halt when:

'Sheet1'!A2 changes value (from blank to i.e. 4)


TIA
 
Hi,

I don't believe the Watch Window can stop code execution. Are you sure you
mean the Watch Window, this window shows the value of a variable as the macro
executes. This is in the VBE (Visual Basic Editor).
 
Shane,

Actually, I do mean the Watch Window ( VBA Exploere>View>Watch Window.

In that window, one can halt the execution of code at the change of a value.

I am not sure of the syntax to watch a cell value of a specified sheet.

EagleOne
 
Hi

If you have the line of code in your module highlighted, then Debug>Add
Watch will bring that line up as the default in the watch Window.

Or you could type in =Range("A1)=20
and set to Break on True

If you set the Watch to =Range("A1)
and set Break on Change, then every time the value in cell A1 changes
the code will halt.
 
Hi Roger,

I agree, but he says the Watch Window codes the stop and you are saying, as
I would that you add the code to break within the module. Isn't this the
case?
 
Roger,

Do you actually mean Range("A1") for Range("A1)?

TIA

EagleOne
 
Do you actually mean Range("A1") for Range("A1)?

Yes, I did. Apologies for the typo. Didn't even notice when I copied and
pasted it again.
 
Debug.Assert will break into the running code when it's expression is
evaluated to FALSE. For example:

Debug.Assert Range("A2").Value <> 4

This line will stop the code when A2 = 4 because the expression A2<>4
= FALSE

Regards,
Dave
 

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