MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 7th, 2002, 05:42 AM   #1
Guest
 
Posts: n/a
Default

I need to run it every 90 mins. Thanks
  Reply With Quote
Old Mar 7th, 2002, 05:50 AM   #2
Dave Hawley
Banned
 
Join Date: Feb 2002
Posts: 1,582
Default

Hi

Try

Sub StartOff()
Application.OnTime Now + TimeValue("00:90:00"), "DoIt"
End Sub

Sub DoIt()
Run "StartOff"
'Your Code
End Sub

Dave Hawley is offline   Reply With Quote
Old Mar 7th, 2002, 08:28 AM   #3
Guest
 
Posts: n/a
Default

I get an error on sub startoff
  Reply With Quote
Old Mar 7th, 2002, 02:35 PM   #4
SamS
Board Regular
 
Join Date: Feb 2002
Location: Brisbane, Down Under
Posts: 533
Default

Make a small change as follows:

Public ThisTime As Double

Sub StartOff()
ThisTime = Now + TimeValue("00:90:00")
Application.OnTime earliesttime:=ThisTime, procedure:="DoIt"

Sub DoIt()
Run "StartOff"
'Your Code
End Sub

SamS is offline   Reply With Quote
Old Mar 7th, 2002, 05:07 PM   #5
Guest
 
Posts: n/a
Default

I am still getting an error BTW I am using Excel 97 if that matters
  Reply With Quote
Old Mar 7th, 2002, 05:34 PM   #6
Barrie Davidson
MrExcel MVP
 
Barrie Davidson's Avatar
 
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
Default

Quote:
On 2002-03-07 16:07, Anonymous wrote:
I am still getting an error BTW I am using Excel 97 if that matters
I think you just need to change the order of the sub named DoIt (see below).

Sub DoIt()
'Your Code
Run "StartOff"
End Sub

Regards,


__________________
Barrie Davidson

"You're only given a little spark of madness. You mustn't lose it." - Robin Williams
Barrie Davidson is offline   Reply With Quote
Old Mar 7th, 2002, 05:35 PM   #7
SamS
Board Regular
 
Join Date: Feb 2002
Location: Brisbane, Down Under
Posts: 533
Default

silly me - you need to change
ThisTime = Now + TimeValue("00:90:00") to
ThisTime = Now + TimeValue("01:30:00") as you as time is in hh:mm:ss or you will get adata type mismatch (also forgot the end sub before sub DoIt())
SamS is offline   Reply With Quote
Old Mar 7th, 2002, 07:07 PM   #8
Guest
 
Posts: n/a
Default

Sam S that works! thanks
  Reply With Quote
Old Mar 7th, 2002, 07:49 PM   #9
Guest
 
Posts: n/a
Default

OK guys the file runs the Marco at the set interval, I changed it to 1 minute to check it, now how do I cut it OFF, when I close the file it will OPEN BACK UP BY ITS SELF! And start running the Marco. thanks
  Reply With Quote
Old Mar 7th, 2002, 09:11 PM   #10
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

I had this similar problem. I have some code that someone on this board helped me with (I'm sorry, i dont remember who ) shuts the worksheet down after it hasnt been used for a certain time, and eventhough the sheets were being closed, after the set time, they opened and closed again.

The problem youre having is that the code is still being run eventhough the file is closed. To stop this, you need to disable the counter. Im not the best person to tell you exactly how to do that but, heres the code I use:

In "ThisWorkbook" I have this code:

'This disables the time coutner and resets it when a caculation is made
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Call Disable
Call SetTime
End Sub

'This disables the time counter and resets it when a sheet is changed
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Call Disable
Call SetTime
End Sub

and in a module, i have this code:


Dim DownTime As Date

'This is the code that the macros in ThisWorkbook calls to set the timer
Sub SetTime()
DownTime = Now + TimeValue("00:15:00")
Application.OnTime DownTime, "ShutDown"
End Sub

'This is the code that the macros in ThisWorkbook calls to close the file
Sub ShutDown()
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub

'This is the code that the macros in ThisWorkbook calls to disable the timer
Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, Procedure:="ShutDown", Schedule:=False
End Sub



Im assuming youll need something similar to the Disable code.

Hope this helps some
robfo0 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:55 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes