Excel Time Function

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

Excel Time Function

Postby boycee » Fri Feb 19, 2010 9:28 am

I am using this code to call a macro every 60 seconds.

I have to manually start the macro first and it seems to do the job.

How can I get the macro to start when I open the workbook automatically?

Sub OnTimeMacro()
Application.OnTime Now + TimeValue("00:01:00"), "Macro2"
End Sub

Sub Macro2()
'
' Macro2 Macro
'

'
ActiveWorkbook.Worksheets("Sorter").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sorter").Sort.SortFields.Add Key:=Range("P1:P200") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sorter").Sort
.SetRange Range("A1:R200")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Call OnTimeMacro
End Sub
boycee
 
Posts: 124
Joined: Fri Nov 25, 2005 1:35 pm

Postby GaryRussell » Fri Feb 19, 2010 10:09 am

In the ThisWorkbook module you can use the Workbook_Open event. Insert the following code into ThisWorkbook

Code: Select all
Private Sub Workbook_Open()
    Macro2
End Sub
User avatar
GaryRussell
Site Admin
 
Posts: 9872
Joined: Fri Nov 18, 2005 8:09 pm
Location: Birmingham, UK

Postby boycee » Fri Feb 19, 2010 10:26 am

GaryRussell wrote:In the ThisWorkbook module you can use the Workbook_Open event. Insert the following code into ThisWorkbook

Code: Select all
Private Sub Workbook_Open()
    Macro2
End Sub


Thanks Gary.
boycee
 
Posts: 124
Joined: Fri Nov 25, 2005 1:35 pm

Postby mak » Sat Feb 20, 2010 6:58 am

GaryRussell wrote:In the ThisWorkbook module you can use the Workbook_Open event. Insert the following code into ThisWorkbook

Code: Select all
Private Sub Workbook_Open()
    Macro2
End Sub



Gary
something like this will it work if I add it in your AutoReloadQuickpickList example.

something like this:?

Option Explicit

Private Sub Workbook_Open()
Application.OnTime TimeValue("05:00:00"), "loadQuickPickList"
Macro2
End Sub
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Postby alrodopial » Sat Feb 20, 2010 7:33 am

mak wrote:
GaryRussell wrote:In the ThisWorkbook module you can use the Workbook_Open event. Insert the following code into ThisWorkbook

Code: Select all
Private Sub Workbook_Open()
    Macro2
End Sub



Gary
something like this will it work if I add it in your AutoReloadQuickpickList example.

something like this:?

Option Explicit

Private Sub Workbook_Open()
Application.OnTime TimeValue("05:00:00"), "loadQuickPickList"
Macro2
End Sub



It will run the macro 'loadQuickPickList' every 5 hours.
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby mak » Sat Feb 20, 2010 7:41 am

[/quote] It will run the macro 'loadQuickPickList' every 5 hours.[/quote]

Eyxaristo :)

Will it work with something like this? (no I am afraid)

Option Explicit

Private Sub Workbook_Open()
Application.OnTime TimeValue("05:00:00"), "loadQuickPickList"
End Sub

Private Sub Workbook_Open()
Macro2
End Sub
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Postby alrodopial » Sat Feb 20, 2010 9:06 am

No I don't think it will.
The first code you posted will run the macro2 at the opening and the loadQuickPickList every 5 hours, is this what you want? One macro at the opening and another every ...
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby mak » Sat Feb 20, 2010 9:29 am

with this one the macro run every morning at 5:00 (it is working fine)
Option Explicit

Private Sub Workbook_Open()
Application.OnTime TimeValue("05:00:00"), "loadQuickPickList"
End Sub

i have also a macro lets say macro2 which run every 1 hour for example
in order to work i have to manual press run macro2 & then it is working fine

so IF possible i would like macro2 to start automatically too.

I need to know more for "theoretical" reasons for the time being...
mak
 
Posts: 1086
Joined: Tue Jun 30, 2009 8:17 am

Postby alrodopial » Sat Feb 20, 2010 9:39 am

A very useful site for excel:
http://www.cpearson.com/excel/topic.aspx

and a very good excel forum:
http://www.mrexcel.com/forum/index.php
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm


Return to Discussion

Who is online

Users browsing this forum: No registered users and 57 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.