ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Change event (https://www.excelbanter.com/excel-programming/394795-worksheet_change-event.html)

Sandy

Worksheet_Change event
 
How can I go through a "Worksheet_Change" event manually to check the code
is working as intended?
I believe inserting a breakpoint after 1st line is a start but I don't know
how to do that!
Step by step would be good!
Sandy



Roger Govier[_3_]

Worksheet_Change event
 
Hi Sandy

Right click on sheet tabView Code
In the grey bar on the left side of the code window, click opposite the line
of code where you want to pause.
This will highlight the row (Brown in my case).
Return to your spreadsheet by pressing Alt + F11

Do the operation that should trigger the code, and return to the code
window. If the code is running, then part of the marked line will be
highlighted Yellow. Using the F8 button you can step through the remaining
lines of code.

If the code is not running, it could be that Application.EnableEvents has
been switched off.

In the Immediate window of the VBE (press Control+G to make it viewable, if
not already shown) enter
Application.EnableEvents = True
and press Enter

Then try invoking the code again.
--
Regards
Roger Govier



"Sandy" wrote in message
...
How can I go through a "Worksheet_Change" event manually to check the code
is working as intended?
I believe inserting a breakpoint after 1st line is a start but I don't
know how to do that!
Step by step would be good!
Sandy




Gary''s Student

Worksheet_Change event
 
Private Sub Worksheet_Change(ByVal Target As Range)
Call sandy
End Sub

and in a standard module:

Sub sandy()
MsgBox ("hi")
End Sub


If sandy needs Target, have the Event code save Target in a public variable
and then modify sandy to use the public variable.
--
Gary''s Student - gsnu200735


"Sandy" wrote:

How can I go through a "Worksheet_Change" event manually to check the code
is working as intended?
I believe inserting a breakpoint after 1st line is a start but I don't know
how to do that!
Step by step would be good!
Sandy




Sandy

Worksheet_Change event
 
Thank you both - Roger's explanation was the one I was really after.
Nice way to check it's running though Gary.
Sandy

"Roger Govier" <rogerattechnology4NOSPAMu.co.uk wrote in message
...
Hi Sandy

Right click on sheet tabView Code
In the grey bar on the left side of the code window, click opposite the
line of code where you want to pause.
This will highlight the row (Brown in my case).
Return to your spreadsheet by pressing Alt + F11

Do the operation that should trigger the code, and return to the code
window. If the code is running, then part of the marked line will be
highlighted Yellow. Using the F8 button you can step through the remaining
lines of code.

If the code is not running, it could be that Application.EnableEvents has
been switched off.

In the Immediate window of the VBE (press Control+G to make it viewable,
if not already shown) enter
Application.EnableEvents = True
and press Enter

Then try invoking the code again.
--
Regards
Roger Govier



"Sandy" wrote in message
...
How can I go through a "Worksheet_Change" event manually to check the
code is working as intended?
I believe inserting a breakpoint after 1st line is a start but I don't
know how to do that!
Step by step would be good!
Sandy







All times are GMT +1. The time now is 10:32 AM.

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