Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Ontime questions

I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be found.
If I create a macro with the name, it functions, but the nexttime does not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Ontime questions

Bruce,

You can't run procedures in a class module, only procedures in a standard
code module. Moreover, you can't declare Public constants in a class module
(which includes regular class modules, the ThisWorkbook module, sheet code
modules, and userform code modules). Declare everything in a standard code
module.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BruceJ" wrote in message
news:VZFnb.54052$HS4.263894@attbi_s01...
I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be found.
If I create a macro with the name, it functions, but the nexttime does not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Ontime questions

Chip,

How do I declare in a "standard code module"?

What is the differance between a class and standard? I now this is probably
very basic to most people here, but....

Thanks
Bruce

"Chip Pearson" wrote in message
...
Bruce,

You can't run procedures in a class module, only procedures in a standard
code module. Moreover, you can't declare Public constants in a class

module
(which includes regular class modules, the ThisWorkbook module, sheet code
modules, and userform code modules). Declare everything in a standard

code
module.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BruceJ" wrote in message
news:VZFnb.54052$HS4.263894@attbi_s01...
I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be found.
If I create a macro with the name, it functions, but the nexttime does

not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Ontime questions

Insert= module gives you a standard code module.

--
Regards,
Tom Ogilvy

"BruceJ" wrote in message
news:ydRnb.55948$Tr4.127761@attbi_s03...
Chip,

How do I declare in a "standard code module"?

What is the differance between a class and standard? I now this is

probably
very basic to most people here, but....

Thanks
Bruce

"Chip Pearson" wrote in message
...
Bruce,

You can't run procedures in a class module, only procedures in a

standard
code module. Moreover, you can't declare Public constants in a class

module
(which includes regular class modules, the ThisWorkbook module, sheet

code
modules, and userform code modules). Declare everything in a standard

code
module.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BruceJ" wrote in message
news:VZFnb.54052$HS4.263894@attbi_s01...
I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be found.
If I create a macro with the name, it functions, but the nexttime does

not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Ontime questions

Bruce,

In VBA, go to the Insert menu and choose Module. Put the code in that
module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"BruceJ" wrote in message
news:ydRnb.55948$Tr4.127761@attbi_s03...
Chip,

How do I declare in a "standard code module"?

What is the differance between a class and standard? I now this is

probably
very basic to most people here, but....

Thanks
Bruce

"Chip Pearson" wrote in message
...
Bruce,

You can't run procedures in a class module, only procedures in a

standard
code module. Moreover, you can't declare Public constants in a class

module
(which includes regular class modules, the ThisWorkbook module, sheet

code
modules, and userform code modules). Declare everything in a standard

code
module.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BruceJ" wrote in message
news:VZFnb.54052$HS4.263894@attbi_s01...
I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be found.
If I create a macro with the name, it functions, but the nexttime does

not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Ontime questions

Thaks!
Is there a way I can tell if an existing module is standard or class?

Thanks
Bruce

"Tom Ogilvy" wrote in message
...
Insert= module gives you a standard code module.

--
Regards,
Tom Ogilvy

"BruceJ" wrote in message
news:ydRnb.55948$Tr4.127761@attbi_s03...
Chip,

How do I declare in a "standard code module"?

What is the differance between a class and standard? I now this is

probably
very basic to most people here, but....

Thanks
Bruce

"Chip Pearson" wrote in message
...
Bruce,

You can't run procedures in a class module, only procedures in a

standard
code module. Moreover, you can't declare Public constants in a class

module
(which includes regular class modules, the ThisWorkbook module, sheet

code
modules, and userform code modules). Declare everything in a standard

code
module.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BruceJ" wrote in message
news:VZFnb.54052$HS4.263894@attbi_s01...
I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be

found.
If I create a macro with the name, it functions, but the nexttime

does
not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Ontime questions

by default if should have a name like module1 if it is a standard module

It will be listed in the project explorer in the VB Editor under the entry
for modules under you workbook/project.

If it is a class module it would be under Class. Any other type class
module would not be listed as it is part of a sheet, thisworkbook or
userform.

--
Regards,
Tom Ogilvy

"BruceJ" wrote in message
news:FYTnb.57751$e01.161947@attbi_s02...
Thaks!
Is there a way I can tell if an existing module is standard or class?

Thanks
Bruce

"Tom Ogilvy" wrote in message
...
Insert= module gives you a standard code module.

--
Regards,
Tom Ogilvy

"BruceJ" wrote in message
news:ydRnb.55948$Tr4.127761@attbi_s03...
Chip,

How do I declare in a "standard code module"?

What is the differance between a class and standard? I now this is

probably
very basic to most people here, but....

Thanks
Bruce

"Chip Pearson" wrote in message
...
Bruce,

You can't run procedures in a class module, only procedures in a

standard
code module. Moreover, you can't declare Public constants in a class
module
(which includes regular class modules, the ThisWorkbook module,

sheet
code
modules, and userform code modules). Declare everything in a

standard
code
module.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BruceJ" wrote in message
news:VZFnb.54052$HS4.263894@attbi_s01...
I am trying to get an ontime routine working.
Here are my questions...
Will it only run MACROS? or can it run a sub function
Where do I decalre the PUBLIC varibles


I tried to following in one of the modules (a_publicStuff):

Public NextTime As Double 'to setup 15 minute time
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "settimer_Click"

(if I put the above in my usercode area, the last two turn red)

and the following is in my userform code area.
Sub StartTimer()

'RunWhen = NextTime
Application.OnTime earliesttime:=NextTime, procedu=cRunWhat, _
schedule:=True

End Sub

Sub settimer_Click()
MsgBox Format(Application.RoundUp(Time * 96, 0) / 96, "hh:mm:ss")
NextTime = NextTime + cRunIntervalSeconds
MsgBox cRunIntervalSeconds

MsgBox Format(NextTime, "hh:mm:ss")


End Sub

When I run my form, I get an error saying the macro can not be

found.
If I create a macro with the name, it functions, but the nexttime

does
not
get incremented, and cRunIntervalSeconds is 0:00

Thanks
Bruce













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 bug? Antonio Excel Discussion (Misc queries) 0 June 9th 06 08:24 PM
OnTime VB [email protected] Excel Discussion (Misc queries) 5 May 17th 06 10:53 PM
OnTime VB [email protected] Excel Worksheet Functions 2 May 16th 06 08:43 PM


All times are GMT +1. The time now is 06:52 AM.

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

About Us

"It's about Microsoft Excel"