View Full Version : Sports league VBA program
Issue:
I'll create a VBA program that will calculate a position in a sports league for my son.
Basic things:
1 won the match = 3 points
1 Drawn match = 1 point for each
Lost 1 match = 0 points
The output should give the following location, team name, goal differnce and score.
Are there any who can help.?
www . billedeupload.dk/photo/2009-10/45222eed/League.jpg.html
The result may look like the following picture:
www . billedeupload.dk/photo/2009-10/86e87cdf/Resultat.jpg.html
EirikDaude
10-14-2009, 05:13 AM
Where do you get the input from? Have you got a worksheet looking something like the picture you posted? And do you want the resulting sheet to display all the teams in the league?
Where do you get the input from? Have you got a worksheet looking something like the picture you posted? And do you want the resulting sheet to display all the teams in the league?
Yes .. My son has started making a website with the Danish football league ..
I have the exact worksheet like what I have posted..
I would really like to have it over all the teams... If possible..
Maybe it be posted on a sheet for it themselves.
EirikDaude
10-14-2009, 05:45 AM
Hmm... In that case my pseudo-code would look something like this:
Make string-array with the team names.
Link each team name to an int-array containing goal-difference and score.
Loop through the appropriate column(s) for each team-name
When found(
if team's goals > other team's goals add 3 to teams score
elseif team's goals = other team's goals add 1 to teams score
add goal-difference to total goal-difference
)
Put team-names, goal-difference and score into the worksheet where you want the results to be.
Sort the resulting table according to score, and then by goal-difference if two scores are equal.
I guess the code will be kinda bulky, but I think it will do the job, if you put it into proper VBA-code.
I don't really want to go into any more detail without being able to experiment in the actual workbook.
Hmm... In that case my pseudo-code would look something like this:
Make string-array with the team names.
Link each team name to an int-array containing goal-difference and score.
Loop through the appropriate column(s) for each team-name
When found(
if team's goals > other team's goals add 3 to teams score
elseif team's goals = other team's goals add 1 to teams score
add goal-difference to total goal-difference
)
Put team-names, goal-difference and score into the worksheet where you want the results to be.
Sort the resulting table according to score, and then by goal-difference if two scores are equal.
I guess the code will be kinda bulky, but I think it will do the job, if you put it into proper VBA-code.
I don't really want to go into any more detail without being able to experiment in the actual workbook.
Thank you. :D it sounds like a good idea. I will try to do the job.
If you want the workbook, then my email is kokogold79@gmail.com
EirikDaude
10-14-2009, 05:59 AM
You're welcome. Though the hard part will be putting that pseudo-code into actual VBA-code. So good luck :)
JP2112
10-14-2009, 10:35 AM
Why not use something like
http://www.xldynamic.com/source/xld.LeagueTable.html
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.