Code:
Sub macro1()
'Dim frm As UserForm
Dim I As Integer
'To could be as many as you want. I only put 25 as a limit.
For I = 1 To 25
Dim a As String
a = Sheet1.Cells(I, 1).Value
Dim b As String
b = ActiveSheet.Cells(I, 2).Value
'get URLs
'option after "URL;" & a
'UserForm1.txtbox1.value
With ActiveWorkbook.ActiveSheet.QueryTables.Add(Connection:="URL;" & a, Destination:=Range("$A$1"))
'With ActiveWorkbook.ActiveSheet.QueryTables.Add(Connection:="URL;" & a, Destination:=Range(b))
.Name = _
"its_details_value_node.html?nsc=true&listId=www_s201_b9233&tsId=BBK01.ED0439"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
'MsgBox "Done!"
End With
Next I
'close all forms
'For Each frm In UserForms
' Unload frm
'Next frm
End Sub
[CODE]
Hello,
Code above is having issue when ran from a form. The code works if it's ran from spreadsheet however when placed in a button in the form it fails with error code 1004. Please help.
I've researched and most of the blogs weren't very helpful.
Thanks.
I use this VBA to pull URLs from Sheet one (craigslist URL) then scrape it up to 25 sites using loop function. This works when manually placed in sheet but not in button of excel.
Comment