Microsoft Office Tutorials and References
In Depth Information
Lesson 23: Managing External Data
‘Add your QueryTable with the connection string
‘and other useful methods you see in the With structure.
With wsDestination.QueryTables.Add _
(Connection:=”URL;” & strURL & strStocks, _
.BackgroundQuery = True
.SaveData = True
.AdjustColumnWidth = True
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = “”“wsod_multiquoteTable”“”
‘Release object variable memory.
Set wsDestination = Nothing
With the worksheet active, you can refresh the data by right-clicking cell A1 and selecting Refresh, as
shown in Figure 23-2. Alternatively, you can execute the VBA expression Range(“A1”).QueryTable
.Refresh in the Immediate window or in a macro. Each time you refresh the data, you see the most
recent version of the information in the data source, including any changes that were made to the data.