I hate asking this question as I fear it will get no replies but I'm completely stumped. I have some code that runs BeforeClose based on a user selection from a user form. It cleans up the entire workbook to delete any unused rows or formulas that are hidden or result in blank values. That works exactly as expected (the clean up code) but it's unpredictable when actually running before close.
Every time I try to debug it using the ways I'm familiar with (stepping through the code, breaking out and testing pieces of code) it works fine. I get no error message when it doesn't work, I just reopen the file and the rows that should have been deleted weren't. When I try it a second time it works fine.
My only guess at this point is that I have some other code that's disabling it somehow, but I sure thought I'd notice that when doing a debug...
My second issue is that my code is complicated and messy because I'm still an apprentice Excel coder at best and I fear an expert will take one look at it and say "I can't work with this - it's too crazy" - so I'm sharing what I THINK you may need to help, but I expect you may need more detail o kindhearted soul who's willing to give this a look!
![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
If you made it through all of that without giving up, any guess why it would work sometimes and not others, or any suggestions on how to test it differently to find the problem myself?![]()
Please Login or Register to view this content.
Bookmarks