Hello,
I am sure this is a simple task but i am quite new to macros and VBs.
I have a list of players from my cricket team and the link to their play cricket web page and their unique player ID.
I know how to set up a web query, however i was hoping there was a quick way to automate the setup. I have around 100 players and i do not wish to spend 2 days setting up web queries for them all. I have recorded the following macro:
Sub PlayCricket()
'
' PlayCricket Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://hitchin.play-cricket.com/scoreboard/individualPerformanceResults.asp?seasonID=26&userID=10532067&ruleTypeID=6101" _
, Destination:=Range("$A$1"))
.Name = _
"individualPerformanceResults.asp?seasonID=26&userID=10532067&ruleTypeID=6101"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = True
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "3"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("O1").Select
Selection.AutoFill Destination:=Range("O1:O5"), Type:=xlFillDefault
Range("O1:O5").Select
End Sub
The URL - (URL;Hitchin CC - Play-Cricket - Individual Performances for SeasonuserID=10532067&ruleTypeID=6101) will be the same for each player apart from the 'userID'. Each player will have there own ID.
I have a list of all the full URLs as above (with the unique IDs) and i also have extracted all the user IDs.
[TABLE="class: grid, width: 1036"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[/TR]
[TR]
[TD]Name
[/TD]
[TD]ID[/TD]
[TD]URL
[/TD]
[/TR]
[TR]
[TD]Paul Smith
[/TD]
[TD]10532067[/TD]
[TD]Hitchin CC - Play-Cricket - Individual Performances for Season[/TD]
[/TR]
[TR]
[TD]Ben Williams[/TD]
[TD]12316605[/TD]
[TD]Hitchin CC - Play-Cricket - Individual Performances for Season[/TD]
[/TR]
[TR]
[TD]Richard Middleditch [/TD]
[TD]10532067[/TD]
[TD]http://hitchin.play-cricket.com/scoreboard/individualPerformanceResults.asp?seasonID=26&userID=10532067&ruleTypeID=6101[/TD]
[/TR]
[TR]
[TD]Joe Elliot [/TD]
[TD]11552467[/TD]
[TD]Hitchin CC - Play-Cricket - Individual Performances for Season[/TD]
[/TR]
</tbody>[/TABLE]
Table 1
What I would like is to be able to run a macro to set up all players in one worksheet (one after the other) then from there i would like to just open the workbook and press update for the new information. Below is the result of the above macro:
[TABLE="class: grid, width: 1096"]
<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[TD]J
[/TD]
[TD]K
[/TD]
[TD]L
[/TD]
[TD]M
[/TD]
[TD]N
[/TD]
[TD]O
[/TD]
[/TR]
[TR]
[TD]Fixture
[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Batting[/TD]
[TD] [/TD]
[TD]Bowling[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Fielding[/TD]
[TD] [/TD]
[TD]Wicket-keeping[/TD]
[TD] [/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Date[/TD]
[TD]Home -vs- Away[/TD]
[TD]Type[/TD]
[TD]Inn[/TD]
[TD]Runs[/TD]
[TD]Overs[/TD]
[TD]Mdns[/TD]
[TD]Runs[/TD]
[TD]Wkts[/TD]
[TD]Ct[/TD]
[TD]ROs[/TD]
[TD]Ct[/TD]
[TD]St[/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD]Click to view scorecard[/TD]
[TD]20/04/2013[/TD]
[TD]Letchworth Garden City CC - 1st XI -vs- 1st XI[/TD]
[TD]Friendly[/TD]
[TD]1[/TD]
[TD]7[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0
[/TD]
[TD]0[/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD]Click to view scorecard[/TD]
[TD]27/04/2013[/TD]
[TD]Preston CC, Herts - 1st XI -vs- 1st XI[/TD]
[TD]Friendly[/TD]
[TD]1[/TD]
[TD]18[/TD]
[TD]3[/TD]
[TD]0[/TD]
[TD]15[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD]Click to view scorecard[/TD]
[TD]11/05/2013[/TD]
[TD]Flitwick CC - 1st XI -vs- 1st XI[/TD]
[TD]League[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]Paul Smith [/TD]
[/TR]
</tbody>[/TABLE]
Table 2
What i would also like is the macro to fill the players name from Table 1 column A to auto fill in columns o in Table 2. Which i am guessing is a bit more work. A1-N2 are headers from the web site, so each player will have these.
I would really preffer this all to be contanied in one sheet and when it is updated the rows will all be shifted down. So next week when another game is played Paul Smiths next week will go in row 6 and the following players information will be shifted down, and so on.
I hope this is enough information and you help will be very welcome.
Regards
I am sure this is a simple task but i am quite new to macros and VBs.
I have a list of players from my cricket team and the link to their play cricket web page and their unique player ID.
I know how to set up a web query, however i was hoping there was a quick way to automate the setup. I have around 100 players and i do not wish to spend 2 days setting up web queries for them all. I have recorded the following macro:
Sub PlayCricket()
'
' PlayCricket Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://hitchin.play-cricket.com/scoreboard/individualPerformanceResults.asp?seasonID=26&userID=10532067&ruleTypeID=6101" _
, Destination:=Range("$A$1"))
.Name = _
"individualPerformanceResults.asp?seasonID=26&userID=10532067&ruleTypeID=6101"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = True
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "3"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("O1").Select
Selection.AutoFill Destination:=Range("O1:O5"), Type:=xlFillDefault
Range("O1:O5").Select
End Sub
The URL - (URL;Hitchin CC - Play-Cricket - Individual Performances for SeasonuserID=10532067&ruleTypeID=6101) will be the same for each player apart from the 'userID'. Each player will have there own ID.
I have a list of all the full URLs as above (with the unique IDs) and i also have extracted all the user IDs.
[TABLE="class: grid, width: 1036"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[/TR]
[TR]
[TD]Name
[/TD]
[TD]ID[/TD]
[TD]URL
[/TD]
[/TR]
[TR]
[TD]Paul Smith
[/TD]
[TD]10532067[/TD]
[TD]Hitchin CC - Play-Cricket - Individual Performances for Season[/TD]
[/TR]
[TR]
[TD]Ben Williams[/TD]
[TD]12316605[/TD]
[TD]Hitchin CC - Play-Cricket - Individual Performances for Season[/TD]
[/TR]
[TR]
[TD]Richard Middleditch [/TD]
[TD]10532067[/TD]
[TD]http://hitchin.play-cricket.com/scoreboard/individualPerformanceResults.asp?seasonID=26&userID=10532067&ruleTypeID=6101[/TD]
[/TR]
[TR]
[TD]Joe Elliot [/TD]
[TD]11552467[/TD]
[TD]Hitchin CC - Play-Cricket - Individual Performances for Season[/TD]
[/TR]
</tbody>[/TABLE]
Table 1
What I would like is to be able to run a macro to set up all players in one worksheet (one after the other) then from there i would like to just open the workbook and press update for the new information. Below is the result of the above macro:
[TABLE="class: grid, width: 1096"]
<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[TD]J
[/TD]
[TD]K
[/TD]
[TD]L
[/TD]
[TD]M
[/TD]
[TD]N
[/TD]
[TD]O
[/TD]
[/TR]
[TR]
[TD]Fixture
[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Batting[/TD]
[TD] [/TD]
[TD]Bowling[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Fielding[/TD]
[TD] [/TD]
[TD]Wicket-keeping[/TD]
[TD] [/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Date[/TD]
[TD]Home -vs- Away[/TD]
[TD]Type[/TD]
[TD]Inn[/TD]
[TD]Runs[/TD]
[TD]Overs[/TD]
[TD]Mdns[/TD]
[TD]Runs[/TD]
[TD]Wkts[/TD]
[TD]Ct[/TD]
[TD]ROs[/TD]
[TD]Ct[/TD]
[TD]St[/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD]Click to view scorecard[/TD]
[TD]20/04/2013[/TD]
[TD]Letchworth Garden City CC - 1st XI -vs- 1st XI[/TD]
[TD]Friendly[/TD]
[TD]1[/TD]
[TD]7[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0
[/TD]
[TD]0[/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD]Click to view scorecard[/TD]
[TD]27/04/2013[/TD]
[TD]Preston CC, Herts - 1st XI -vs- 1st XI[/TD]
[TD]Friendly[/TD]
[TD]1[/TD]
[TD]18[/TD]
[TD]3[/TD]
[TD]0[/TD]
[TD]15[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]Paul Smith [/TD]
[/TR]
[TR]
[TD]Click to view scorecard[/TD]
[TD]11/05/2013[/TD]
[TD]Flitwick CC - 1st XI -vs- 1st XI[/TD]
[TD]League[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]-[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]Paul Smith [/TD]
[/TR]
</tbody>[/TABLE]
Table 2
What i would also like is the macro to fill the players name from Table 1 column A to auto fill in columns o in Table 2. Which i am guessing is a bit more work. A1-N2 are headers from the web site, so each player will have these.
I would really preffer this all to be contanied in one sheet and when it is updated the rows will all be shifted down. So next week when another game is played Paul Smiths next week will go in row 6 and the following players information will be shifted down, and so on.
I hope this is enough information and you help will be very welcome.
Regards