Worksheet_Change event

  • Thread starter Thread starter Sandy
  • Start date Start date
S

Sandy

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
 
Hi Sandy

Right click on sheet tab>View 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.
 
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.
 
Thank you both - Roger's explanation was the one I was really after.
Nice way to check it's running though Gary.
Sandy
 
Back
Top