Hi,

I found the following thread by searching the internet http://www.excelforum.com/excel-prog...using-vba.html and used the code to carry out a web query.

I have 6 links in a worksheet entitled URL. The first time I used the macro it downloaded the table from each of the 6 links but subsequent times it has only downloaded the table from the first link but has done so 6 times.

I am no expert with VBA and was hoping someone may be able to point out where the issue lies. I have included the code below.

Thanks,

Andy

Sub WebData()
Dim wSU As Worksheet
Dim wSR As Worksheet
Dim wSS As Worksheet
Dim iForRow As Integer
Dim iLastRow As Integer
Dim sURL As String
Set wSU = ThisWorkbook.Sheets("URLs")
Set wSR = ThisWorkbook.Sheets("Results")
Set wSS = ThisWorkbook.Sheets("Scrape")
Application.ScreenUpdating = False
iLastRow = wSU.Cells(wSU.Rows.Count, "a").End(xlUp).Row
For iForRow = 1 To iLastRow Step 1
sURL$ = wSU.Cells(iForRow, "a").Value
With wSS.QueryTables.Add(Connection:= _
"URL;" & sURL, Destination:=wSS.Range("A1"))
.Name = "?action=alltips"
.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 = "6"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
wSR.Cells(iForRow + 1, "a").Value = wSS.Range("a2").Value
wSR.Cells(iForRow + 1, "b").Value = wSS.Range("a3").Value
wSR.Cells(iForRow + 1, "c").Value = wSS.Range("b5").Value
Next iForRow
Application.ScreenUpdating = True
MsgBox "Process Completed"
End Sub