+ Reply to Thread
Results 1 to 5 of 5

Optimizing a fantasy baseball lineup

  1. #1
    Registered User
    Join Date
    04-30-2014
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    3

    Optimizing a fantasy baseball lineup

    I'm looking to optimize a projected point value of a fantasy baseball lineup under the constraints of a salary cap.

    In the worksheet attached, I have projections for a number of players organized by position. I'm hoping to automatically select the combination of players that will provide the maximum point value ('Xfactor' on this sheet in column K) with 1 C, 1B, 2B, 3B, SS, and 3 OF with the available salary cap listed in cell P11.

    Thanks in advance.

    baseball.xlsx

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,243

    Re: Optimizing a fantasy baseball lineup

    Hi zigzagman and welcome to the forum,

    Find the attached where I've done these things....

    1. Created a table in N18:Q25 determine the start and end of each player position row.
    2. In O3:O10 I then did a random lookup of a player of that type using the table above and put there name in Col O
    3. I used VLookup from Column O to display their pay and XFactor.
    4. I then summed the new players salary and XFactor in Row 11.

    Now - here is the cool part. Every time you press F9 it will recalculate and pick a new team because of the RandBetween formulas in Column O. Try it a few times.

    I did a macro record to copy what is picked from Columns O:Q over to Columns T:W

    I then wrote a very short VBA code to copy the pick to the columns to the right IF the salary was greater than Zero and the XFactor was greater than what was already there. Click on the "New Pick Try" button a few times to see this work. Then put a Zero in W11 and do it some more times. It will only copy the new randomly picket team over if the XFactor is greater than the best previous pick.

    Then that was all pretty easy so I wrote a little loop to do the above 5000 times. It takes about 3 seconds to do 5000 random picks and only remember the best one. You can do another 5000 in 6 seconds.

    Did I do any wonderful logic to make sure my team pick was the best? Heck no, but I did 10000 random picks and only kept the best one. I guess the logic is that the computer is fast and can get close to the best team...

    See the attached and see if it meets what you are looking for.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    04-30-2014
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Optimizing a fantasy baseball lineup

    WOW! That's phenomenal!

    I only have one question. I update this list daily with the actual size of the list getting larger and smaller depending on who is playing that day.

    As long as I update the start row and end row, will everything still work as expected?

    Thanks again!

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,243

    Re: Optimizing a fantasy baseball lineup

    "As Expected"
    is a pretty big goal to achieve.

    I think if you have your data sorted by position so all the C are together and 1B are togethere... That would be the first problem. Then .. Let me look at the code as 140 was the last row for today....

    I see that the formulas in columns O to Q would also need updating for it to work with more or less players.....

    I'd use a Dynamic Named Range for the Players and Positions to be more generic.
    Using the names manager you could create a DNR called
    Players = OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)+2,11)

    Then use this Name in the formulas in the O:Q cells.

    I'd also use a fancy CSE (Control+Shift+Enter) formula for the Max and Min of Start and End Row for player positions. YOU WILL STILL NEED TO SORT BY PLAYER POSITION.

    Lastly in this newer version I made sure the 3 outfielders aren't the same person as the first version didn't have that check.

    Now, maybe you could do this daily by simply copying in new data...
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-30-2014
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Optimizing a fantasy baseball lineup

    Great!

    Thanks very much for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Scalable baseball lineup from stats
    By lavudyar in forum Excel General
    Replies: 17
    Last Post: 08-03-2020, 04:22 PM
  2. formula for fantasy baseball!
    By drnick in forum Excel General
    Replies: 8
    Last Post: 09-19-2014, 07:04 PM
  3. [SOLVED] Fantasy Baseball Transactions
    By dmarzo1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2013, 07:27 AM
  4. Formula for Fantasy Baseball
    By lycomingwarrior in forum Excel General
    Replies: 1
    Last Post: 11-12-2008, 05:17 PM
  5. Fantasy Baseball Spreadsheet
    By jed_vii in forum Excel General
    Replies: 6
    Last Post: 05-22-2008, 12:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1