Disable Background Refresh for External Data VBA

rupertlo

Board Regular
Joined
Sep 10, 2014
Messages
53
Hi there, I have searched the forum and apologise if this question has been asked before (which I am sure it has).

I have an Excel spreadsheet with some VBA which pulls stock data from Yahoo finance, via a macro.

Even when I am not running the macro to fetch the data, the worksheet is incredibly slow. It recalculates very quickly (it is a small worksheet) but moving from, say, cell A1 to A2 takes about five seconds rather than being instantaneous.

Is there a way to disable background query refresh for all external data connections in VBA. I would plan to stick in some script at the start of my VBA to enable background refresh and then switch it off at the end of the macro.

Many thanks,

Rupert.
 
Is there a way to disable background query refresh for all external data connections in VBA. I would plan to stick in some script at the start of my VBA to enable background refresh and then switch it off at the end of the macro.
Code:
Public Sub Disable_Background_Refresh()

    Dim ws As Worksheet
    Dim qt As QueryTable

    For Each ws In ThisWorkbook.Worksheets
        For Each qt In ws.QueryTables
            qt.BackgroundQuery = False
        Next
    Next
    
End Sub
and True to enable background queries.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top