0

I've made a code that downloads data using webquery from website (several pages) in a loop. Everything is great but instead of downloading data in the same column ("B2") if to set ActiveSheet.QueryTables(1) it creates one table starting in B2 but on the next loop (next webpage) it will overwrite the previously downloaded data again starting in B2.

It have to add next webpage data into worksheet in another range of cells (100 cells down from B2 in the same column) but even though I've changed the range the data is downloaded in the same position.

If to change i in ActiveSheet.QueryTables(i) it creates multiple tables in different columns (not in the same one).

With ActiveSheet.QueryTables(i)
    .Connection = "URL;" & page
    .Destination = Range(Cells(n + 1, 2), Cells(n + 100, 2))
    .Refresh
End With
i = i + 1
RubberDuck
  • 11,933
  • 4
  • 50
  • 95
Samuel
  • 83
  • 2
  • 14

1 Answers1

0

Possibly this solution will solve your problem (assuming that n starts with 1):

.Destination = Range(Cells((n-1)*100 + 2, 2), Cells((n * 100) + 1, 2))

BTW, what you rather need as a .Destination value is this line:

.Destination = Cells((n-1)*100 + 2, 2)

See this MSDN Reference for .Destination property.

Kazimierz Jawor
  • 18,861
  • 7
  • 35
  • 55