[quote user="Barry Lothian"]Nearing the end of a long VBA project...[/quote]
VBA projects contain cans of worms. Usually those stay sealed, but occasionally they spring a leak. When that happens the worms escape into your code and morph into inexplicable bugs.
The VBA IDE is not good at housekeeping, particularly for large projects. A long or large project tends to have lots of code that has been reworked, moved or deleted. All of those contribute to leaks in the can of worms. When mysterious things happen, such as those you describe, it's time to take drastic action.
Here's a similar tale of woe.
Rebuild a VBA project
What you're going to do is export all your code to text files, create a new project, import all the code into that new project, then discard the old project. It's a tedious process, but worthwhile. I do this with every large project once customer has accepted the prototype...
- Open the VBA project
- Right-click each model, form and class and export them to text files
- Close the VBA project
- Create a new VBA project. Choose the new name carefully
- Import each code text file into the new project
- Close the new VBA project
At this point you have a new VBA project that contains all your code and a sealed can of worms. With luck, the above process will have stopped inexplicable things happening when your code executes. Good luck!