Looping a Web Query

gator2

New Member
Joined
Nov 25, 2008
Messages
36
For work I need to pull order information off a website. I've created an Excel file with a list of order numbers on one sheet (row J) and would like to populate the information from each order onto a separate sheet. I've created a web query with parameters to pull the order I select, then create a new worksheet. When I run the macro, the parameter box pops up, I click on the next order # from my list, the query runs and creates my next worksheet.

My current code is below. I'm trying to automate the process to prevent me from manually clicking the next order #, allowing the macro to pull the first order # from cell J2, adding it to my web query url, place the web query results in sheet 1 cell A1, pull the second order # from cell J3, place the results in sheet 2 cell A1, and so on until it reaches the end of the order #s. Any help would be greatly appreciated.

Sub MyFileWebQuery()
'
' MyFileWebQuery Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Users\reason\Desktop\Web Queries\MyFile.iqy", _
Destination:=Range("$A$1"))
.Name = "MyFile"
.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
End With
Sheets.Add After:=Sheets(Sheets.Count)
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,203,644
Messages
6,056,525
Members
444,872
Latest member
agutt

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