ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax to stop code in Watch Window (https://www.excelbanter.com/excel-programming/390578-syntax-stop-code-watch-window.html)

[email protected]

Syntax to stop code in Watch Window
 
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

ShaneDevenshire

Syntax to stop code in Watch Window
 
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).
--
Cheers,
Shane Devenshire


" wrote:

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


[email protected]

Syntax to stop code in Watch Window
 
Shane,

Actually, I do mean the Watch Window ( VBA ExploereViewWatch 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

ShaneDevenshire wrote:

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).


Roger Govier

Syntax to stop code in Watch Window
 
Hi

If you have the line of code in your module highlighted, then DebugAdd
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.

--
Regards

Roger Govier


wrote in message
...
Shane,

Actually, I do mean the Watch Window ( VBA ExploereViewWatch 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

ShaneDevenshire wrote:

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).




ShaneDevenshire

Syntax to stop code in Watch Window
 
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?

--
Cheers,
Shane Devenshire


"Roger Govier" wrote:

Hi

If you have the line of code in your module highlighted, then DebugAdd
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.

--
Regards

Roger Govier


wrote in message
...
Shane,

Actually, I do mean the Watch Window ( VBA ExploereViewWatch 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

ShaneDevenshire wrote:

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).





Roger Govier

Syntax to stop code in Watch Window
 
The OP actually said "halt", which is exactly what it does.

--
Regards

Roger Govier


"ShaneDevenshire" wrote in
message ...
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?

--
Cheers,
Shane Devenshire


"Roger Govier" wrote:

Hi

If you have the line of code in your module highlighted, then
DebugAdd
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.

--
Regards

Roger Govier


wrote in message
...
Shane,

Actually, I do mean the Watch Window ( VBA ExploereViewWatch
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

ShaneDevenshire wrote:

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).







[email protected]

Syntax to stop code in Watch Window
 
Thanks Roger & Shane

"Roger Govier" wrote:

The OP actually said "halt", which is exactly what it does.


[email protected]

Syntax to stop code in Watch Window
 
Roger,

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

TIA

EagleOne

"Roger Govier" wrote:

Hi

If you have the line of code in your module highlighted, then DebugAdd
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.


Roger Govier

Syntax to stop code in Watch Window
 
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.

--
Regards

Roger Govier


wrote in message
...
Roger,

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

TIA

EagleOne

"Roger Govier" wrote:

Hi

If you have the line of code in your module highlighted, then
DebugAdd
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.




Dave Miller

Syntax to stop code in Watch Window
 
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



All times are GMT +1. The time now is 12:07 AM.

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