Hello all
I am trying to import data from a non password protected site. I have a list of urls in sheet 1 all from the same site. when i run the code below it seems to run through all the urls however in sheet 2 there are many blank columns and at the bottom the last url has worked. this is the case regardless of how many urls i have and i am perplexed as to why any ideas? thanks
Dan
I am trying to import data from a non password protected site. I have a list of urls in sheet 1 all from the same site. when i run the code below it seems to run through all the urls however in sheet 2 there are many blank columns and at the bottom the last url has worked. this is the case regardless of how many urls i have and i am perplexed as to why any ideas? thanks
Dan
Code:
Sub Importdata()
Sheets(2).Activate
i = 1
Do Until Sheets(1).Cells(i, 1) = ""
myquery = Sheets(1).Cells(i, 1)
Sheets(2).Cells(1, 1) = myquery
myrow = Sheets(2).UsedRange.Rows.Count + 1
Do
myrow = myrow - 1
Loop Until Sheets(2).Cells(myrow, 1) <> ""
myrow = myrow + 1
With Sheets(2).QueryTables.Add(Connection:= _
"URL;" & myquery, Destination:=Sheets(2).Cells(myrow, 1))
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
i = i + 1
Loop
End Sub