I have attached a workbook that is a skeletal version of a workbook that takes raw data from timesheet records and generates reports for a set of projects. I've stripped out all the code except the setup portion where it deletes all the worksheets that were generated the last time the macros were run. The worksheets being deleted each correspond to a project. The other worksheets are identified as static worksheets, meaning that they should always be there and therefore should not be deleted.
I have reduced the code down to only that code causing a problem. The command button on the Controls sheet invokes a Sub in Module Main called CreateReports. That Sub calls ResetSheets, which deletes all non-static sheets. It in turn calls a function in Module Exclude called StaticSheet that compares a sheet name to a list of static sheets, and returns a Boolean indicating whether the given sheet is static. If it is static, it is not deleted.
The problem is that execution in the function StaticSheet is abandoned prematurely. There is a comment at the line of code where this happens. There is nothing at that point in the code that should allow this Function to be exited. There is no error, it just continues execution in the caller. The return value of the function is never set, therefore it always returns False.
This problem occurs regardless of whether I run the code normally, or step through it using F8. The file is attached but here is all the code:
Module Main:
Module Exclude:Please Login or Register to view this content.
Please Login or Register to view this content.
Bookmarks