Hello,
Looking for some help on writing a VBA script that will execute a refresh macro every hour on the hour. Not very experienced with VBA so help will be greatly appreciated.
Using Excel 2010
Hello,
Looking for some help on writing a VBA script that will execute a refresh macro every hour on the hour. Not very experienced with VBA so help will be greatly appreciated.
Using Excel 2010
Last edited by warmajam; 07-11-2014 at 02:45 PM. Reason: spelling
Refresh WHAT macro? You offered no information as to what you need.
Please ensure you mark your thread as Solved once it is. Click here to see how.
If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.
I have a file that has a query and would it to automatically refresh every hour.
I haven't tested this to see what it does at midnight or anything but it should work. It will run when called and then run again every hour on the hour unless you set a public boolean to true. If you set that boolean to true the timer will exit without doing anything the next time it comes time to run and not run any more until called again. Actually it runs 1 second after the hour just in case of issues with now() not flipping to the new hour before the next cycle.![]()
Public stopTimer As Boolean 'public variable so we can easily stop our timer Sub runEveryHour() 'run something every hour 'set stopTimer somewhere else (a button macro maybe) and next time this happens it will exit instead of looping If stopTimer Then stopTimer = false GoTo TheEnd end if 'put code here that should run this time and then run again on the hour every hour 'this makes it repeat itself on the hour every hour until stopped Application.OnTime TimeSerial(Hour(Now), 0, 0) + TimeValue("01:00:01"), "runEveryHour" 'this is where we skip to if we want to exit the loop TheEnd: End Sub
Last edited by slomer; 07-11-2014 at 04:15 PM.
Thank you for the code but evidently I am not as advanced as I thought I was. Going to need a step by step process to implement this code into my file as I am lost reading through your code.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks