Import Data from web

cicada

Board Regular
Joined
Jan 10, 2010
Messages
79
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

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
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

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
Back
Top