Hello all. I signed up here to ask for some help with the code I am going to post. The code works, but I sure it is not the most efficient way to do what I am doing and there are some problems that arise after many hours of execution that have baffled me to the point I need fresh eyes and more excel knowledgeable people to look at it.
In a nutshell, this code is behind a report that has to print each morning at 7am or desired time and generate a .csv file for storage backup of the data. It is also triggering database queries once an hour for new data. I give the user input boxes to set the Print time, view minutes and seconds to next update of data, I display current time to be compared with Next Print Time and give them input boxes to give a file path where the csv file will be written. It all works fine.....for a while.
I think my problem stems from keeping the time displayed accurately in a cell for viewing and using it for the compare to know when to print and save.
What I have noticed is that the longer the code runs, the more it loads up on memory and processor time to the point it will eventually crash. I have tried to slow the code down with WAIT commands, Sleep commands and experimented with some For/While looping but all of my attempts have affected either the time updating or paused function of the spreadsheet while waiting or sleeping.
I don't do a lot of excel vba so my methodology may be laughable, but for better or worse, here it is. Any help with this will be much appreciated.
With the exception of a couple of buttons coming from Sheet1 writing to Global bits, all code is in this one module. A screenshot of the user input area is also attached. Thank you.
Bookmarks