+ Reply to Thread
Results 1 to 14 of 14

Macro for making golf teams randomly

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    47

    Macro for making golf teams randomly

    I want to create a macro for making random golf teams (completely random - no factor of handicap, age - just names only). I have the lookup for player ID done, I have the formula for how many 4-somes and 5-somes done, but I cannot write the VB code for "making teams". I have the format (including the button) completely done. I've tried to start this macro - but I cannot do it.

    This is what I started with - but I do not think I am on the right track:

    Please Login or Register  to view this content.
    Could someone take a look the attachment and let me know what the code would be for the "TeamPicker" tab? Thank you. SHG, gave me a RAND formula that may well work (and for that I am grateful), but I really want the format on the attachment and I really want to be able just to hit the button for making random teams without any consideration of handicap or anything else. Again, thank you for your help.
    Last edited by rwhite713; 07-26-2010 at 12:34 PM.

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

    Re: Macro for making golf teams randomly

    Hey Randy,
    Try the attached to see if it does what you want.
    Attached Files Attached Files

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro for making golf teams randomly

    Try this

    This will make random teams for any number of players entered.

    I have added some new formulae to calculate the optimum number of teams, and provided warnings if combinations are not possible.(less than 4 players, or 6,7,or 11 players)

    Put this code in the sheet module for Sheets("TeamPicker")
    Please Login or Register  to view this content.

    This code runs on the Worksheet_SelectionChange event therefore there is no need to use a button. Try the Demo workbook attached.

    Check all the new formulae in Sheets("TeamPicker"), the code uses this.

    Hope this helps
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

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

    Re: Macro for making golf teams randomly

    After looking at your workbook and seeing the Stableford point formula I remembered an easier method.
    The Choose function is much easier to deal with. Here is my suggestion,

    =Choose(Score - Par +4 , 7,5,3,2,1,0,-1,-1,-1,-1,-1,-1) should give your correct Stableford points.

    Example: Player shoots 4 on a par 5 hole. So the Score - Par + 4 = 3rd number in choose list = 3

    The cool part about using Choose is that if you want to make an Eagle worth 4 instead of 5 points you would simply need to change the 5 to a 4 in the Choose list.

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Macro for making golf teams randomly

    Cross-post here: Ozgrid
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  6. #6
    Registered User
    Join Date
    07-01-2010
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Macro for making golf teams randomly

    Marvin, it almost works. The number of 4-somes and 5-somes in cells D5 and D6 need to manipulate making the teams. If we have 20 players that would be (4) 5-somes, but when I hit the make the teams button it has (2) 5-somes and (2) 4-somes for a total of 18 players not 20. And some of the players are duplicated.

    So how can I get the macro to look over at column B and pull the names then make the teams according to how many 4-somes and/or 5-somes are in cells D5 & D6?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-01-2010
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Macro for making golf teams randomly

    PERFECT!!! Thank you very much for this. I just don't see how you guys think of this stuff.

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

    Re: Macro for making golf teams randomly

    Hey Randy,
    I used tricks from dealing a deck of cards and a little Diophantine Equation help for the answer. Also, you taught me something about conditional formatting on your sheets. I've always wanted to color Birds Green, Pars No Color and Boggys Red. I found that conditional formatting using formulas and relative formatting really did what I wanted. See the attached sheet and look for conditional formatting rules...
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-01-2010
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Macro for making golf teams randomly

    Glad it worked for you. Going back to your TeamPicker, what would be really cool is if you had 3 macros for team picking. The first would be 4-somes and 5-somes just like I have it. Then have another button for 2-somes and one for 3-somes. We have a draw sometimes at the end of a round for 2-somes and 3-somes as side bets.

    The next thing I will be working on is a spreadsheet for settling bets. Mainly 2-downs and 1-downs. Do you by chance have those formulas?

  10. #10
    Registered User
    Join Date
    08-18-2011
    Location
    Hamilton New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro for making golf teams randomly

    I am impressed with the Team picker spreadsheet and associated coding.
    I have recently returned to teaching High School students and have a need to generate groups of 4 & 3 as well as 4 & 5. I have modified the Golf Teampicker spreadsheet to do the 4 and 5 groups, and this with the exception of one addition is working superbly.
    My coding knowledge is poor in VB as I have not coded much since MSDos Basic days. I have managed to make changes to the original code but this is cosmetic only and I can not get the code to populate the class list correctly. I have included some excel comments in key cells to explain the problem. At the moment I can get the code to make the correct number of rows but I can not get it to only fill the correct items per row. I have generated the number of foursomes and threesomes based on a matrix sheet.

    Also an extra bonus would be to be able to select only those present to generate the groups from. I have put a tick control box in on sheet to show the chosen students to make the class list for inclusion into the groups.
    Each Groupsheet would load the ID number's next to the ticked boxes only and then contiguously populate the first column with present students ID numbers.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-07-2012
    Location
    Coon Rapids, MN
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Macro for making golf teams randomly

    This is awesome. You guys rock! Glad I found this post.

  12. #12
    Registered User
    Join Date
    03-08-2015
    Location
    amsterdam
    MS-Off Ver
    2010
    Posts
    8

    Re: Macro for making golf teams randomly

    I am really new to macros but this is brilliant but I would like to have teams of 3 of 4 as we play weekly( 21 persons) but no duplicates together until necessary !.

    How would I do that ?

    Cheers,
    Mary

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

    Re: Macro for making golf teams randomly

    Hi Mary and welcome to the forum,

    You will need to start your own thread as that is one of the rules of this forum. You can't add a new request on someone else's question. Go to the VBA Forum and create a question and supply a Sample workbook showing what you have and what you want. Attach the sample using "Go Advanced" and then click on the Paper Clip Icon. After you do the above, Private Message me so I will find your new thread and give you some answers.

    Marv
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  14. #14
    Registered User
    Join Date
    03-08-2015
    Location
    amsterdam
    MS-Off Ver
    2010
    Posts
    8

    Re: Macro for making golf teams randomly

    Hi Marv,

    Thanks, didn't know that, will do as you advise.

    cheers,
    Mary

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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