Hello - I need an excel spreadsheet built using developer functions. I cant seem to get it correct.
I have the code from another website which is built to do precisely what I am after.
I want to use excel to generate every permutation/combination of a list of 10-20 golfer names. The purpose of doing so is for mass entering daily fantasy pga contests.
My goal is to assign a pool of 10-20 hand selected players and use excel to create the lineups.
The constraints of the lineups are as follows:
Each lineup has $50,000 in "salary" to be used. You can not go over this salary, but obviously you can stay under the 50k limit.
Golfers are assigned there own salary, generally ranging anywhere from $5500 to $13000 depending on that weeks pga tournament and strength of field.
Each lineup consists of 6 golfers, which again add to or remain under the 50k cap.
Here would be a hypothetical list of my favorite players and their salaries:
Rory McIlroy $13,000
Jordan Spieth $12,600
Jason Day $10,100
Justin Rose $10,000
Louis Oosthuizen $9,600
Sergio Garcia $9,100
Henrik Stenson $9,000
Brooks Koepka $8,000
Charl Schwartzel $7,800
Tiger Woods $7,500
Branden Grace $7,300
Danny Lee $7,000
Robert Streb $6,400
Cameron Percy $5,900
Matt Jones $5,800
John Daly $5,500
Obviously this is going to result in a TON of combinations lol, and only lineups using around $49,500 in salary would be of any use. After running the program, I would then have to go through the file and hand select the generated lineups I like. Until I can find a better way of generating preferred exposure rates of players, uploading personal fantasy point projections (assembled in a whole different spreadsheet / for another time) which would basically be a "lineup optimizer".
For now I am just interested in figuring out how to use excel to run each possible combinations of a list of names and staying within the salary constraints. I realize this is probably a very big task, and may be a bit advanced for the excel noob I am, but I have the time to learn and think a project as such is the best way for me to learn excel and have fun with my hobby.
Thanks guys, I hope the explanation is clear and that we can work something out!
Can you turn this code into a functioning spreadsheet that I can download and use?
Code here:
Sub test()
i = 1
For player_1 = 0 To 1
For player_2 = 0 To 1
For player_3 = 0 To 1
For player_4 = 0 To 1
For player_5 = 0 To 1
For player_6 = 0 To 1
For player_7 = 0 To 1
For player_8 = 0 To 1
For player_9 = 0 To 1
For player_10 = 0 To 1
For player_11 = 0 To 1
For player_12 = 0 To 1
For player_13 = 0 To 1
For player_14 = 0 To 1
For player_15 = 0 To 1
For player_16 = 0 To 1
If player_1 + player_2 + player_3 + player_4 + player_5 + player_6 + player_7 + player_8 + player_9 + player_10 + player_11 + player_12 + player_13 + player_14 + player_15 + player_16 = 6 Then
Total = player_1 * Cells(1, 2) + player_2 * Cells(2, 2) + player_3 * Cells(3, 2) + player_4 * Cells(4, 2) + player_5 * Cells(5, 2) + player_6 * Cells(6, 2) + player_7 * Cells(7, 2) + player_8 * Cells(8, 2) + player_9 * Cells(9, 2) + player_10 * Cells(10, 2) + player_11 * Cells(11, 2) + player_12 * Cells(12, 2) + player_13 * Cells(13, 2) + player_14 * Cells(14, 2) + player_15 * Cells(15, 2) + player_16 * Cells(16, 2)
If Total <= 50000 And Total > 45000 Then
Cells(1, i + 3) = player_1
Cells(2, i + 3) = player_2
Cells(3, i + 3) = player_3
Cells(4, i + 3) = player_4
Cells(5, i + 3) = player_5
Cells(6, i + 3) = player_6
Cells(7, i + 3) = player_7
Cells(8, i + 3) = player_8
Cells(9, i + 3) = player_9
Cells(10, i + 3) = player_10
Cells(11, i + 3) = player_11
Cells(12, i + 3) = player_12
Cells(13, i + 3) = player_13
Cells(14, i + 3) = player_14
Cells(15, i + 3) = player_15
Cells(16, i + 3) = player_16
Cells(17, i + 3) = Total
i = i + 1
End If
End If
Next Next Next Next Next Next Next Next Next Next Next Next Next Next Next Next
End Sub