Internet Query control Refresh Rate

Posted on 2011-05-03
Last Modified: 2012-05-11
I want to control the refresh rate of my query, the minimum value i can put is 1 minute, i want it in seconds.

Can i create a query using VBA and control his refresh rate?
Question by:sharkyboy
    LVL 41

    Accepted Solution

    Ok - let's work with OnTime, again :)

    Create a subroutine that refreshes your query when you run it, and call that subroutine - "RefreshMyQuery"

    Put the below in a public module, and change "refreshTime" variable to however many seconds you want between refreshes...
    Public runWhen As Double
    Sub refreshQuery()
    Dim refreshTime As Double
        Call RefreshMyQuery
        refreshTime = 15
        runWhen = Now() + refreshTime / 86400
        Application.OnTime earliesttime:=runWhen, procedure:="RefreshQuery", schedule:=True
    End Sub
    Sub StopTimer()
        On Error Resume Next
        Application.OnTime earliesttime:=runWhen, procedure:="RefreshQuery", schedule:=False
    End Sub

    Open in new window

    Also, put a call to StopTimer on workbook exit...

    LVL 41

    Expert Comment

    See attached with all in place.  Just add the code that refreshes the query... And update the refreshTime variable for # seconds between refreshes...



    Author Closing Comment

    Yeah :) !!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now