Web refresh macro (2003 SP3)

steveh
SilverLounger
Posts: 1952
Joined: 26 Jan 2010, 12:46
Location: Nr. Heathrow Airport

Web refresh macro (2003 SP3)

Post by steveh »

Morning all

I have a workbook with quite a few web queries and for which I want to record a web refresh macro for. If I record the macro and right click on the first set of data and select refresh data will it refresh all of the web queries or only that one?
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin

User avatar
HansV
Administrator
Posts: 78494
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Web refresh macro (2003 SP3)

Post by HansV »

The recorded macro would act on one web query only - the one selected when you run the macro.

Here is a macro that will update all external data in a workbook:

Code: Select all

Sub UpdateAllWebqueries()
  Dim wsh As Worksheet
  Dim qtb As QueryTable
  Application.ScreenUpdating = False
  For Each wsh In ActiveWorkbook.Worksheets
    For Each qtb In wsh.QueryTables
      qtb.Refresh BackgroundQuery:=False
    Next qtb
  Next wsh
  Application.ScreenUpdating = True
End Sub
Best wishes,
Hans

steveh
SilverLounger
Posts: 1952
Joined: 26 Jan 2010, 12:46
Location: Nr. Heathrow Airport

Re: Web refresh macro (2003 SP3)

Post by steveh »

HansV wrote:The recorded macro would act on one web query only - the one selected when you run the macro.

Here is a macro that will update all external data in a workbook:
Hi Hans

Fantastic as usual, the Christmas hamper is getting bigger and bigger!! :grin:
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin