vba - DoEvents, Waiting, and Editing -


i have set of code contains:

application.wait (now + timevalue("4:00:00")) 

this pausing macro 4 hour window 3 (when finishs running code) till 7 (when should resume). code on endless loop essentially.

i want user able have control during time edit cells. have tried

doevents 

but have not found way keep macro running, yet provide control user during time when macro doing nothing waiting.

any insight appreciated. thanks!

edit:

one more followup question. created macro reference actual macro "production_board". want macro run time , refresh possible. using goto startagain, tries start launch macro again before macro has started due "ontime" delay interval.

how make sub runmacro start again second macro "production_board" finishes?

sub runmacro startagain: dim hour integer dim ot string hour = 0 ot = "empty" hour = sheets("calculations").range("dr1").value ot = sheets("black").range("d4").value if ot = "y"     if hour = 3 or hour = 4     application.ontime timevalue("05:00:00"), "aespire_production_board"     else     application.ontime + timevalue("00:00:30"), "aespire_production_board"     end if else     if hour = 3 or hour = 4 or hour = 5 or hour = 6     application.ontime timevalue("07:00:00"), "aespire_production_board"     else     application.ontime + timevalue("00:00:30"), "aespire_production_board"     end if doevents goto startagain 

instead of wait, try ontime. demonstrate, paste in normal module , run test. range a1 of active sheet increment every 5 seconds , you'll able work in between. works if in edit mode when 5 seconds elapses:

sub test()     test2 end sub  sub test2()     activesheet.cells(1, 1).value = activesheet.cells(1, 1).value + 1     application.ontime + timevalue("00:00:5"), "test2" end sub 

note ontime statement @ end of sub calls sub again recursively. here's more info.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -