I've inherited a large Excel application that cashes data retreived from an Access database in VBA global variable arrays when the application starts up. It then builds worksheets from scratch by adding a default sheet to the workbook and inserting all formating and data. All calculations are done with VBA modules so no Excel formula are inserted into the sheets. When finished with a sheet, it is deleted from the workbook.
This was working before I got into the code. I added a new feature that would not compile until I changed the object library references. Now all that cashed data in global VBA variables clears out apparently mostly when sheets are deleted but not always then and sometimes at other unknown events. So I am the goat who has broken the application.
Everything I have read and tried tells me the original design is a real bad idea. I have read posts on this and other forums denouncing the idea of using any global VBA variables for any reason. I have never seen them used before in Excel on this scale. My personal preference would be to use templates rather than default sheets, retrieve data from Access as I needed it, and use worksheet formulae in preference to VBA. But I can't rewrite this application. I have rewritten one function to use a template that avoids writing controls to the sheet. Inserting controls onto a sheet seemed to be an intermitent cause of global variable clearing.
I have gone through the code and put a lot of non array variables onto a hidden worksheet with named ranges that are the same name as the global variable and am trying to reload the data each time it clears. This application is large and complex and has been "designed" and written by many people who have preceded me. Getting this reload to work correctly is not easy. Figuring out what to load and what calculations to perform for each application feature is also a long term effort.
Does anyone have any ideas on how to stop the global variables from clearing so I can get on with life? I can slowly rewrite code as I understand the functions over a long period of time once I get some semblance of credibility back.
This was working before I got into the code. I added a new feature that would not compile until I changed the object library references. Now all that cashed data in global VBA variables clears out apparently mostly when sheets are deleted but not always then and sometimes at other unknown events. So I am the goat who has broken the application.
Everything I have read and tried tells me the original design is a real bad idea. I have read posts on this and other forums denouncing the idea of using any global VBA variables for any reason. I have never seen them used before in Excel on this scale. My personal preference would be to use templates rather than default sheets, retrieve data from Access as I needed it, and use worksheet formulae in preference to VBA. But I can't rewrite this application. I have rewritten one function to use a template that avoids writing controls to the sheet. Inserting controls onto a sheet seemed to be an intermitent cause of global variable clearing.
I have gone through the code and put a lot of non array variables onto a hidden worksheet with named ranges that are the same name as the global variable and am trying to reload the data each time it clears. This application is large and complex and has been "designed" and written by many people who have preceded me. Getting this reload to work correctly is not easy. Figuring out what to load and what calculations to perform for each application feature is also a long term effort.
Does anyone have any ideas on how to stop the global variables from clearing so I can get on with life? I can slowly rewrite code as I understand the functions over a long period of time once I get some semblance of credibility back.