Import Web Data - Repeat macro

leeksleeks

Board Regular
Joined
Oct 31, 2013
Messages
96
Hi,

A former colleague of mine wrote the code below and has now left. I am wanting to modify the code so that it can repeat the macro over and over again. The limitations of this is that you have to go into each webpage one by one and paste it in, wait for the macro to run and then repeat the process over again for the next page. What I would like it to do is to ask for the number on the end of the webadress to be put into the popup box, and then ask for another pop up box to ask the number of the last webpage and to then work its way through from the first one to the last one.

This is what I mean for the webpages:

http://www.espncricinfo.com/west-indies-v-pakistan-2013/engine/match/645645.html
http://www.espncricinfo.com/west-indies-v-pakistan-2013/engine/match/645647.html

So I would like the first popup box to ask for the first code (654645) and then the next one to ask for the last webpage (645647) and so then the macro runs for 654645 and then 645646 and finally 645647.

Is there anyway you can make the url =http://www.espncricinfo.com/west-indies-v-pakistan-2013/engine/match/ and then replace the 645645 with 'i' that would then refer to the pop up boxs?

Below is the code that he wrote.

Please let me know if you need any more information.

Cheers


Sub one()


'Create new Scorecard sheet
Dim url As String
Dim matchtype As String
url = "URL;" & "" & InputBox("Please enter Scorecard URL") & ""
matchtype = InputBox("Enter match type (International = I, Domestic = D)")


ActiveWorkbook.Worksheets.Add.Name = "Scorecard"
With ActiveSheet.QueryTables.Add(Connection:= _
url, Destination _
:=Range("A1"))
.Name = "455234"
.FieldNames = True
.RowNumbers = True
.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
.Refresh BackgroundQuery:=False
End With




'Update url to look at overs comparison
url = url & "?view=comparison"

'Create new Comparison sheet
ActiveWorkbook.Worksheets.Add.Name = "Comparison"
With ActiveSheet.QueryTables.Add(Connection:= _
url, Destination _
:=Range("A1"))
.Name = "455234"
.FieldNames = True
.RowNumbers = True
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.Refresh BackgroundQuery:=False
End With

End Sub
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

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