Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find %ontime & SUMIF ontime ie: find matching sets within Range... Chris T-M Excel Worksheet Functions 3 October 10th 08 08:14 PM
.ontime Grrrrrumpy Excel Discussion (Misc queries) 2 April 8th 07 04:18 PM
OnTime VB [email protected] Excel Discussion (Misc queries) 5 May 17th 06 10:53 PM
Error using OnTime Method Sam Excel Programming 3 April 28th 06 07:30 PM
about ontime uma[_2_] Excel Programming 0 January 21st 06 06:33 AM


All times are GMT +1. The time now is 03:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"