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
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