Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Schedule a Macro to run every 5 minutes

Hello,

Can anyone tell me (in real simple terms) how to run a macro every 5 minutes.

I'd like to hit my hot button "Ctr-Q" and then have it run every 5 minutes
for ever (or until I close the spreadsheet).

I already have the macro done, I just need to add the part I'm asking. I
would ask that you "idiot proof" it for me as I've tried to read Chip
Pearson's page but it was too difficult for me to follow.
Thanks,
atheobody
  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Schedule a Macro to run every 5 minutes

Additional examples

http://www.cpearson.com/excel/ontime.htm

"Atheobody" wrote:

Hello,

Can anyone tell me (in real simple terms) how to run a macro every 5 minutes.

I'd like to hit my hot button "Ctr-Q" and then have it run every 5 minutes
for ever (or until I close the spreadsheet).

I already have the macro done, I just need to add the part I'm asking. I
would ask that you "idiot proof" it for me as I've tried to read Chip
Pearson's page but it was too difficult for me to follow.
Thanks,
atheobody

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Schedule a Macro to run every 5 minutes

Hello,

I read that page but it doesn't make sense to me. I just don't undestand.
Isn't there an example you could copy and paste for me that I could copy and
paste into my macro?

"JMB" wrote:

Additional examples

http://www.cpearson.com/excel/ontime.htm

"Atheobody" wrote:

Hello,

Can anyone tell me (in real simple terms) how to run a macro every 5 minutes.

I'd like to hit my hot button "Ctr-Q" and then have it run every 5 minutes
for ever (or until I close the spreadsheet).

I already have the macro done, I just need to add the part I'm asking. I
would ask that you "idiot proof" it for me as I've tried to read Chip
Pearson's page but it was too difficult for me to follow.
Thanks,
atheobody

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Schedule a Macro to run every 5 minutes

Thanks! Where speficially is the VBA help for ONTIME. You mean in Excel
help on my Excel program? Or on this forum? I'm still very confused.

"Don Guillett" wrote:

look in the vba help for ONTIME

--
Don Guillett
SalesAid Software

"Atheobody" wrote in message
...
Hello,

Can anyone tell me (in real simple terms) how to run a macro every 5
minutes.

I'd like to hit my hot button "Ctr-Q" and then have it run every 5 minutes
for ever (or until I close the spreadsheet).

I already have the macro done, I just need to add the part I'm asking. I
would ask that you "idiot proof" it for me as I've tried to read Chip
Pearson's page but it was too difficult for me to follow.
Thanks,
atheobody






  #7   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Schedule a Macro to run every 5 minutes

Sorry - I must have read over the part where you mentioned you had already
been to Chip's website. I can't give any examples better than what Chip has
already done, so I can only repost his code and offer a little explanation.

These are the variable declarations that go at the top of your vba module.
You will need to change "The_Sub" to the name of your macro that you want to
run every 5 minutes.

Public RunWhen As Double
Public Const cRunIntervalSeconds = 300 ' five minutes
Public Const cRunWhat = "The_Sub" '<<<<< CHANGE


This procedure is called from "The_Sub". This instructs VBA to run
"The_Sub" again in 5 minutes.

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _
schedule:=True
End Sub

This is the macro you want to run every 5 minutes and should be linked to
your hotkey, Ctrl-q. Since your macro is already done, you just need to add
StartTimer to the end of it to get it to run again in 5 minutes.

Sub The_Sub()
'
' your code here
'
StartTimer '<<< Put at the end of your macro
End Sub

As Chip pointed out, even after you close the workbook, Excel will open it
and run your macro in 5 minutes unless you stop the timer. This is a macro
you could assign to a button to stop the timer.

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedu=cRunWhat, schedule:=False
End Sub


Alternatively, you could have excel stop the timer process automatically by
putting the stop timer procedures in a workbook close event handler. Instead
of putting it in a regular vba code module, you have to put it in the
ThisWorkbook module (in the vba editor, you have to have the Project Explorer
open (Ctrl-R) to see the various modules of your project.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedu=cRunWhat, schedule:=False
End Sub


If you need more info on how to navigate the vba editor, you should visit
David McRitchies web site. He has a few tutorials that will likely help.
Here is one on getting started w/macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm



"Atheobody" wrote:

Hello,

I read that page but it doesn't make sense to me. I just don't undestand.
Isn't there an example you could copy and paste for me that I could copy and
paste into my macro?

"JMB" wrote:

Additional examples

http://www.cpearson.com/excel/ontime.htm

"Atheobody" wrote:

Hello,

Can anyone tell me (in real simple terms) how to run a macro every 5 minutes.

I'd like to hit my hot button "Ctr-Q" and then have it run every 5 minutes
for ever (or until I close the spreadsheet).

I already have the macro done, I just need to add the part I'm asking. I
would ask that you "idiot proof" it for me as I've tried to read Chip
Pearson's page but it was too difficult for me to follow.
Thanks,
atheobody

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
how do I email amacro? leo Excel Worksheet Functions 24 August 9th 06 02:47 PM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Schedule an Excel macro ledzepe Excel Discussion (Misc queries) 2 August 4th 06 07:20 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM


All times are GMT +1. The time now is 06:53 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"