Querying multiple web tables and put put them on another sheet vertically

vincentH

New Member
Joined
Jul 5, 2016
Messages
1
Hi,
I am still new to excel vba and I am asking for your help. I have tried to query soccer league tables for different leagues but I don't know how to use loops. I want to query tables for different leagues (those with home and away) and put then on another sheet one after the other(skip one row after each table). There should also be an indicator that shows the table and the respective league. The website I am using is Football stats and results | SoccerSTATS.com. Below is the code that I have recorded in excel. I understand that what I only need to change on the link is the parameter but to make it dynamic has become an issue to me. I have so many leagues that I want to pull for example, league=china, league=Australia etc.. Your help will be greatly appreciated.




Sub Soccerwidetables()
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.soccerstats.com/widetable.asp?league=usa", Destination:=Range("$A$1"))
Name = "widetable.asp?league=usa"
FieldNames = True
RowNumbers = False
FillAdjacentFormulas = False
PreserveFormatting = True
RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """btable"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Columns("S:V").Select
Selection.Delete Shift:=xlToLeft
Rows("23:44").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-42
Range("A1:W21").Select
Selection.Cut
Sheets.Add After:=ActiveSheet
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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