![]() |
ontime error
The following code gives me the error "macro The_Sub cannot be found". What is wrong? The code is enterend in the Workbook module and the ontime does execute 10 seconds after I open the workbook. That is when I get the error. Public RunWhen As Double Public RunWhat As String Public myOffset As Double Sub Workbook_Open() myOffset = 0 StartTimer End Sub Sub Workbook_Close() StopTimer End Sub Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, 10) RunWhat = "The_Sub" Application.OnTime earliesttime:=RunWhen, procedu=RunWhat, schedule:=True End Sub Sub The_Sub() Range("A4").Offset(0, myOffset) = myOffset myOffset = myOffset + 1 StartTimer End Sub Sub StopTimer() On Error Resume Next Application.OnTime ealiesttime:=RunWhen, procedu=RunWhat, schedule:=False End Sub -- gmferg1 ------------------------------------------------------------------------ gmferg1's Profile: http://www.excelforum.com/member.php...o&userid=34191 View this thread: http://www.excelforum.com/showthread...hreadid=553061 |
ontime error
This should all be in A general module (insert=Module in the VBE)
Public RunWhen As Double Public RunWhat As String Public myOffset As Double Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, 10) RunWhat = "The_Sub" Application.OnTime earliesttime:=RunWhen, procedu=RunWhat, schedule:=True End Sub Sub The_Sub() Range("A4").Offset(0, myOffset) = myOffset myOffset = myOffset + 1 StartTimer End Sub Sub StopTimer() On Error Resume Next Application.OnTime ealiesttime:=RunWhen, procedu=RunWhat, schedule:=False End Sub ------------- This should be in the ThisWorkbook module: Sub Workbook_Open() myOffset = 0 StartTimer End Sub Sub Workbook_Close() StopTimer End Sub -- Regards, Tom Ogilvy "gmferg1" wrote in message ... The following code gives me the error "macro The_Sub cannot be found". What is wrong? The code is enterend in the Workbook module and the ontime does execute 10 seconds after I open the workbook. That is when I get the error. Public RunWhen As Double Public RunWhat As String Public myOffset As Double Sub Workbook_Open() myOffset = 0 StartTimer End Sub Sub Workbook_Close() StopTimer End Sub Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, 10) RunWhat = "The_Sub" Application.OnTime earliesttime:=RunWhen, procedu=RunWhat, schedule:=True End Sub Sub The_Sub() Range("A4").Offset(0, myOffset) = myOffset myOffset = myOffset + 1 StartTimer End Sub Sub StopTimer() On Error Resume Next Application.OnTime ealiesttime:=RunWhen, procedu=RunWhat, schedule:=False End Sub -- gmferg1 ------------------------------------------------------------------------ gmferg1's Profile: http://www.excelforum.com/member.php...o&userid=34191 View this thread: http://www.excelforum.com/showthread...hreadid=553061 |
ontime error
That works now. Thanks. -- gmferg1 ------------------------------------------------------------------------ gmferg1's Profile: http://www.excelforum.com/member.php...o&userid=34191 View this thread: http://www.excelforum.com/showthread...hreadid=553061 |
All times are GMT +1. The time now is 09:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com