web query + loop

eran3185

Board Regular
Joined
Apr 28, 2007
Messages
142
Hi
I want to make a web query that copy this page: ipad | eBay in column A from A1.
Than I want to copy the "next page": ipad | eBay in column A from A1001.
Than I want to copy the "next page": ipad | eBay in column A from A2001 etc...

I try this code but it doesnt work :(

Sub Macro1()
'
' Macro1 Macro
'

'

Dim aa As Integer
Dim bb As Integer

For aa = 1 To 4 Step 1
For bb = 1 To 4001 Step 1000


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&_nkw=ipad&_pgn=" & aa, _
Destination:=Range("$A$" & bb))
.Name = "i.html?_from=R40&_sacat=0&_nkw=ipad&_pgn=1"
.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

Next bb
Next aa


End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,375
Messages
6,124,592
Members
449,174
Latest member
chandan4057

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