largeselection
Active Member
- Joined
- Aug 4, 2008
- Messages
- 358
I have a simple spreadsheet and I want it to create a web query based on a list of URLs I list.
In my sheet I list the URLs one every 3 rows (because the web query table it pulls back is 3 rows). So currently the loop is working, but it's pulling the same URL back rather than changing so something funky is in my code and I don't see it.
So I have 3 different URLs listed and it loops through and adds the web query part for just the first URL next to all 3.
In my sheet I list the URLs one every 3 rows (because the web query table it pulls back is 3 rows). So currently the loop is working, but it's pulling the same URL back rather than changing so something funky is in my code and I don't see it.
Code:
Sub CreateContents()
Dim ID As String
ID = Selection.Value
Range("A3").Select
Do Until IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1, 0)) And IsEmpty(ActiveCell.Offset(2, 0))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & ID & "", Destination:=Selection.Offset(0, 1))
.Name = ID
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveCell.Offset(3, 0).Select
Loop
End Sub
So I have 3 different URLs listed and it loops through and adds the web query part for just the first URL next to all 3.