creates a QueryTable object on the active worksheet and sets its data source to a single table from a Web page at the designated location:
Public Sub ImportWeb()
Dim qt As QueryTable
Set qt = ActiveSheet.QueryTables.Add(Connection:=" URL;http://finance.yahoo.com/q?s=^DJI&d=v1", _
Destination:=Range("A1"))
With qt
.name = "DJIQuery"
.WebSelectionType = xlSpecifiedTables
.WebTables = "16" ' DJI table
.WebFormatting = xlWebFormattingNone
.EnableRefresh = True
.RefreshPeriod = 5 'Unit in minutes
.Refresh 'Execute query
End With
Set qt = Nothing
End Sub
Related examples in the same category