14-Sep-2020 : Ghost break?

  • by

Your code compiles perfectly and has worked thousand of times before, but suddenly it starts giving you a nasty error message: ‘Code execution has been interrupted’.  It looks like the one you get when you press Ctrl-Break or when your code produces an error which you haven’t trapped, but you didn’t touch Ctrl-Break (did you?), and in any case this this one has an extra option: ‘Continue’.

Easy choice: ‘Continue’, of course.  Click.  And continues it does.

However, moments later it stops again.  You hit ‘Continue’ again.  It stops again.  If you’re looping through thousands of database records or worksheet cells, it just… keeps… on… happening.

This is called a ‘Ghost Break’.  I’d never heard of it until it happened to me and I was convinced it was happening because I’d done something wrong, and maybe I had, but I couldn’t for the life of me work out what it was.  So I was careful not to save any changes I’d made to my Excel workbook code (just in case), then reloaded it and ran my code again.  And >sigh< – it started happening again.

Don’t worry though – you haven’t done anything wrong and there’s a good way to get around it, or at least it’s worked for me every time I’ve tried it.  Not that it’s happened to me very often – maybe three or four times in ten years – but this appears to be a reliable cure:-

1. When the dialog box appears, press ‘Debug’.
2. Press Ctrl+Break twice.
3. Click ‘Run’ to resume running the code.
4. Save your file at the earliest opportunity.

Did this article help you at all?  If it did, or if you’ve found another reliable fix for the ‘Ghost Break’, please let me know via this contact form or email me.