T
Tomski
Hi Guys,
I'm trying to produce a spreadsheet that pulls infomation fro
different web pages throughout the day. It needs to pull quite a larg
amount of information from different web pages hence I wanted to produc
a subroutine which could be called with different variables for each we
page, i.e. url, field, destination, etc.
To actually produce the query I recorded a macro and then used the cod
it produced. I then changed the URL to url, a string variable whic
holds the urls of the pages. The destion address was changed t
destination, a range variable to store the destionation location, an
the webTable was changed to table also a string variable to store th
table number. This is shown below.
With ActiveSheet.QueryTables.Add(Connection:= _
url, Destination:= destination)
.Name = "q?s=%5EFTSE&m=L_137"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = table
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
I'm not even sure if all this is needed, but it does then seem to wor
correctly if called with one set of variables, or at first, however i
I then add more code and start trying to call it with others i
doesn't. The error shown below is thrown:
'The destination range is not on the same worksheet that the Quer
table is being created on.'
Does anybody know how to solve this, or maybe tidy up my web query s
that it can be used in the way I would like.
Thanks again
Tom:
I'm trying to produce a spreadsheet that pulls infomation fro
different web pages throughout the day. It needs to pull quite a larg
amount of information from different web pages hence I wanted to produc
a subroutine which could be called with different variables for each we
page, i.e. url, field, destination, etc.
To actually produce the query I recorded a macro and then used the cod
it produced. I then changed the URL to url, a string variable whic
holds the urls of the pages. The destion address was changed t
destination, a range variable to store the destionation location, an
the webTable was changed to table also a string variable to store th
table number. This is shown below.
With ActiveSheet.QueryTables.Add(Connection:= _
url, Destination:= destination)
.Name = "q?s=%5EFTSE&m=L_137"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = table
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
I'm not even sure if all this is needed, but it does then seem to wor
correctly if called with one set of variables, or at first, however i
I then add more code and start trying to call it with others i
doesn't. The error shown below is thrown:
'The destination range is not on the same worksheet that the Quer
table is being created on.'
Does anybody know how to solve this, or maybe tidy up my web query s
that it can be used in the way I would like.
Thanks again
Tom: