Auto Refresh

Please post any questions regarding the program here.

Moderator: 2020vision

Auto Refresh

Postby Shaun » Mon Sep 15, 2008 7:26 am

Hi.

I need a macro for auto refresh at a set time. i have imported external data to use with the software for other markets but the best i can get excel to do is 1 minute refresh, i would like to set the macro to refresh at a minimum 10 seconds any help please, the Mr Excel site is down.
Shaun
 
Posts: 435
Joined: Fri May 09, 2008 11:11 pm
Location: Kellerberrin, Western Australia

Postby Ian » Mon Sep 15, 2008 8:45 am

Application.Ontime is the command you need.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby Shaun » Mon Sep 15, 2008 12:54 pm

I found this code on the internet and it works very well, but is there a way to input data on one sheet while another sheet updates the 2 sheets data is linked.

Code: Select all
Private Sub Workbook_Open()
'Monitor the F12 key and when pressed run the ToggleRefresh procedure
Application.OnKey "{F12}", "ToggleRefresh"

'The refresh process will be off by default when the book is opened
'If you want it on then run this line below.
'Note because the RefreshOn variable is false by default and ToggleRefresh
'changes it to the opposite then RefreshOn will be changed to True and the
'RefreshQuery procedure will be called by the ToggleRefresh procedure.
Call ToggleRefresh

End Sub



Code: Select all
'A public variable that will stay in memory while the book is open
'The value of this variable will be False by default.
'Its used as an indicator so you know whether to refresh or not in the RefreshQuery procedure
Public RefreshOn As Boolean
Public RunWhen As Double

Public Sub ToggleRefresh()
'Toggle the refresh to the opposite that it is now
'ie if its currently false then the variable will now be true and visa versa
RefreshOn = Not RefreshOn

If RefreshOn = True Then
'If RefreshOn is true you want to start the refresh process
    Call RefreshQuery
    MsgBox "Web Query Refreshing is ON." & vbLf & vbLf & _
        "To toggle refreshing ON/OFF press the F12 key.", vbInformation, "Web Query Refresh Status"
Else
    'stop the pending ontime procedure
    On Error Resume Next
   Application.OnTime RunWhen, "RefreshQuery", schedule:=False
    On Error GoTo 0
    MsgBox "Web Query Refreshing is OFF." & vbLf & vbLf & _
    "To toggle refreshing ON/OFF press the F12 key.", vbInformation, "Web Query Refresh Status"
End If

End Sub


Public Sub RefreshQuery()
Dim Qrytbl As QueryTable, Sh As Worksheet

'Change this to the name of your sheet that holds the web queries
Set Sh = Sheets("Data")

For Each Qrytbl In Sh.QueryTables
'If the query isnt already refreshing then refresh it
    If Not Qrytbl.Refreshing Then
        On Error Resume Next
        Qrytbl.refresh False
        On Error GoTo 0
    End If
Next Qrytbl

'Repeat this procedure every 30 seconds. The false argument should clear
'the Ontime event if its in memory ready to run (ie stop it running twice in
'quick succession). You check to see if RefreshOn is true before repeating
'the procedure again
If RefreshOn = True Then
    RunWhen = Now + TimeValue("00:00:05")
    On Error Resume Next
    Application.OnTime RunWhen, "RefreshQuery"
    On Error GoTo 0
End If

End Sub
Shaun
 
Posts: 435
Joined: Fri May 09, 2008 11:11 pm
Location: Kellerberrin, Western Australia

Postby Ian » Mon Sep 15, 2008 2:01 pm

Do you have the web queries in more than one sheet ? If so, you can use ActiveWorkbook.RefreshAll to refresh them all in one go.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby Shaun » Mon Sep 15, 2008 2:54 pm

They are only on one sheet the other sheet uses them as a reference, but when i have the data sheet updateing i can't type on the other sheet.

Anyway to have the Data sheet silintly update like BA does and still alowe me to type.
Shaun
 
Posts: 435
Joined: Fri May 09, 2008 11:11 pm
Location: Kellerberrin, Western Australia

Postby Ian » Mon Sep 15, 2008 3:41 pm

I don't think you can. In fact, whilst you are refreshinng the web query, I don't think BA is updating the sheet either.
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham


Return to Help

Who is online

Users browsing this forum: Google [Bot] and 66 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.