excel - Call Application.OnTime with fully qualified path to sub? -


i have spreadsheet implemented timer in automatically update formula every 10 seconds. working great until open spreadsheet. assumption was still trying run timer() on wrong sheet. so, tried switching absolute calls. here full code:

dim timeractive boolean sub starttimer()     start_timer end sub private sub start_timer()     timeractive = true     application.ontime now() + timevalue("00:00:10"), "timetrack.xlsm!tracker.timer" end sub sub stop_timer()     timeractive = false end sub sub timer()     dim tracker worksheet     set tracker = workbooks("timetrack.xlsm").sheets("tracker")     tracker.range("o1").value = "timer stopped"     'on error resume next     if timeractive         tracker.range("o2").value = time         application.ontime now() + timevalue("00:00:10"), "timetrack.xlsm!tracker.timer"         tracker.range("n:n").calculate     end if     tracker.range("o1").value = "" end sub 

specifically, i'm getting error on application.ontime line:

cannot run macro ''s:\onedrive...!docs\timetrack.xlsm'!tracker.timer'. macro may not available in workbook or macros may disabled.

the path shows in error correct. wrong? what's weird seems run in starttimer() sub without issue.

to refer procedure in worksheet, need use worksheet.codename , not worksheet.name :

application.ontime now() + timevalue("00:00:10"), thisworkbook.name & "!" & me.codename & ".timer" 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -