PDA

View Full Version : Solved: help w/ ONTIME



lijon
09-14-2010, 10:49 AM
Help! ...I've borrowed from other sources and can feel I'm close ...but can't make this macro work.
I know the opening event triggers "starttimer" because the word 'Loaded' appears ...but the "refresher" macro doesn't run for some reason.
Am I messing up somewhere? Maybe in the declaration? Pls Help!

...in ThisWkbk

Private Sub workbook_open()
Call starttimer
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call stoptimer
End Sub

...in Module 1:

Public Const cRunWhat = "refresher"
Sub starttimer()

Windows("myfile.XLS").Activate
Sheets("GDR").Select
Range("A2").Value = "loaded"

Application.OnTime TimeSerial(13, 38, 0), cRunWhat, True

End Sub

Sub stoptimer()

On Error Resume Next
Application.OnTime RunWhen, cRunWhat, False

End Sub

Sub refresher()

Range("A3").Value = "done"
Windows("myfile.XLS").Activate
Sheets("GDR").Select
Range("d5:e15").Select
Application.Run "RefreshCurrentSelection"
Range("A4").Value = "done2"

End Sub

Thanks,
L

Bob Phillips
09-14-2010, 11:41 AM
Public Const cRunWhat = "refresher"
Public RunWhen As Double

Sub starttimer()

Windows("myfile.XLS").Activate
Sheets("GDR").Select
Range("A2").Value = "loaded"

RunWhen = TimeSerial(13, 38, 0)
Application.OnTime RunWhen, cRunWhat, , True

End Sub

Sub stoptimer()

On Error Resume Next
Application.OnTime RunWhen, cRunWhat, , False

End Sub

Sub refresher()

Range("A3").Value = "done"
Windows("myfile.XLS").Activate
Sheets("GDR").Select
Range("d5:e15").Select
Application.Run "RefreshCurrentSelection"
Range("A4").Value = "done2"

End Sub

Bob Phillips
09-14-2010, 11:44 AM
Public Const cRunWhat = "refresher"
Public RunWhen As Double

Sub starttimer()

Windows("myfile.XLS").Activate
Sheets("GDR").Select
Range("A2").Value = "loaded"

RunWhen = TimeSerial(13, 38, 0)
Application.OnTime RunWhen, cRunWhat, , True

End Sub

Sub stoptimer()

On Error Resume Next
Application.OnTime RunWhen, cRunWhat, , False

End Sub

Sub refresher()

Range("A3").Value = "done"
Windows("myfile.XLS").Activate
Sheets("GDR").Select
Range("d5:e15").Select
Application.Run "RefreshCurrentSelection"
Range("A4").Value = "done2"

End Sub

lijon
09-14-2010, 12:05 PM
XLD - Thanks ever so much for this. Really really appreciate it. Best. Lijon