Looping through web queries - result placement

DKeller100

New Member
Joined
Feb 15, 2009
Messages
14
I have written some code to loop through a series of web pages (my thanks to this board for getting me started on the process) and am having some problem with the placement of the resulting page.

Here's the snippet:

For i = 2 To m
Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;" & URL & urlquery, Destination:=Cells(1, 1))
With qt
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = False
.SaveData = False
z = z + 20
End With


Despite the Destination:=Cells(1, 1)), which should place following sheets directly after the last data line, the query still places the results in A1 thereby erasing the previous sheets data.

I have tried the RefreshStyle property :
.RefreshStyle = xlInsertRows
with the same results. Is there another property I'm missing?

Also any suggestions as to how I might be selective of the tables imported would be helpful. In a query file I can say Selection=. How might I incorporate that into a dynamic call?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
instead of destation cells(1,1)
make a variable "dest" as range
set dest=cells(rows.count,"a").end(xlup).offset(1,0)
and
the code wil be
destination:=dest

try something on these lines.
 
Upvote 0

DKeller100

New Member
Joined
Feb 15, 2009
Messages
14
Thanks, that seems to do it as far as placement. I still need to select only the table I need fromt he web page.
 
Upvote 0

DKeller100

New Member
Joined
Feb 15, 2009
Messages
14
Disregard last comment. Combination of WebSelectionType and WebTables properties didthe trick.

All done. Yea!
 
Upvote 0

Forum statistics

Threads
1,191,026
Messages
5,984,209
Members
439,878
Latest member
melodysc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top