Why does my Excel VBA application break in Worksheet_Change even though no breakpoint is set?


Sheet1 of the application listens for Worksheet_Change events. When I open the workbook, the very first change I make to Sheet1 breaks in Worksheet_Change (the "sub" line is highlighted in yellow, but there is no breakpoint icon on the line). I am forced to press F5 to allow the VBA to continue. After that, any changes I make to Sheet1 are handled without breaking.


EDIT: I may have found a fix, but it doesn't explain why this happened in the first place.  Here's what I did:  I opened the workbook, but before making any change to Sheet1, I did a Debug -> Clear All Breakpoints, then immediately saved the workbook and closed.  The next time I opened the workbook and made my first change to Sheet1, the code did not break at Worksheet_Change.


It seems like a sticky breakpoint bug in VBA. Is there something that I could have done to cause it?  Is there a better fix?


Office 365

0 Replies