Sample code is stated below.
Workbook Sample: https://www.box.net/shared/x11kv1xl9bpqfdj6llk0
NOTE: This will retrieve data from a webpage only if that is available
in a table.
Sub getTableFromWeb()
Dim queryTableFromWeb As QueryTable
Dim strTableIndex As String
'table number to fetch
strTableIndex = 1
'change the URL as per your requirement
Set queryTableFromWeb = ActiveSheet.QueryTables.Add( _
Connection:="URL;http://www.weatheronline.co.uk/India/
Mumbai.htm", _
Destination:=Range("A1"))
With queryTableFromWeb
.WebSelectionType = xlSpecifiedTables
.WebTables = strTableIndex
.Refresh BackgroundQuery:=False
.SaveData = True
End With
Set queryTableFromWeb = Nothing
End Sub
Workbook Sample: https://www.box.net/shared/x11kv1xl9bpqfdj6llk0
NOTE: This will retrieve data from a webpage only if that is available
in a table.
Sub getTableFromWeb()
Dim queryTableFromWeb As QueryTable
Dim strTableIndex As String
'table number to fetch
strTableIndex = 1
'change the URL as per your requirement
Set queryTableFromWeb = ActiveSheet.QueryTables.Add( _
Connection:="URL;http://www.weatheronline.co.uk/India/
Mumbai.htm", _
Destination:=Range("A1"))
With queryTableFromWeb
.WebSelectionType = xlSpecifiedTables
.WebTables = strTableIndex
.Refresh BackgroundQuery:=False
.SaveData = True
End With
Set queryTableFromWeb = Nothing
End Sub
No comments:
Post a Comment